[ModAPI] Terminal Controls can no longer be attached to base IMyTerminalBlock

Gwindalmir shared this bug 12 months ago
Solved

Having a terminal control attached to a block which is only a MyTerminalBlock, not a more derived class, does not work anymore. The controls are not added, and do not appear in the terminal.

This is a bug in the modapi, which broke in 1.185, and is still broken in 1.187. The last version this worked in was 1.184.


I've attached both a test world, and a test mod.

STR:

  1. Load world
  2. Access terminal via Control Panel block placed in world
  3. In 1.184, notice there is a button labeled "Dial" just below "Custom Data". In 1.185+, there is no button.

Comments (10)

photo
1

https://steamcommunity.com/sharedfiles/filedetails/?id=1489125269

had reported it too via mail, before i was able to login here. Being waiting for this fix for one of my mods.

photo
3

Hello,

I just reported the issue, thank you.

We will update the thread once we know more.

Thank you.


Kind Regards

Keen Software House: QA Department

photo
1

I noticed something similar when I was trying to add a modded List to the controls of the Jump Drive.

when I try to get all Controls the Jump-Drive has I just got an empty list. And it removed all Controls from the Jumpdrive itself.

var controls = new List<IMyTerminalControl>();
MyAPIGateway.TerminalControls.GetControls<IMyJumpDrive>(out controls);

logger.WriteLine(controls.Count + "");
My logger always writes 0 and the Terminal of the Jump drive is completely gone. For some reason. Would not expect a Get Call to actually change something. Seems to be a side effect

photo
1

This is quite odd. I modify Jumpdrives aswell and it works fine for me?

This outputs me all the Controls but doesnt change anything

            List<IMyTerminalControl> controls = new List<IMyTerminalControl>();
            MyAPIGateway.TerminalControls.GetControls<IMyJumpDrive>(out controls);
            foreach (IMyTerminalControl current in controls)
            {
                MyUtils.Log(current.id);
            }

photo
2

this indeed is very weird. Ill take a look at it again.

photo
1

Can someone verify that the bug caused here, affects the bug that's reported here? (Remote terminal access to grids can only be accessed through the Remote Access interface, not the Open Terminal Interface button if the engineer is too far away)


Trying to see which report best highlights the root cause.

photo
1

The original issue I reported is now fixed.

If you want to see an example of how to modify the jump drive, or other blocks, you can look at my FTL or Stargate mods.

https://steamcommunity.com/sharedfiles/filedetails/?id=341822890

Here's code that lets you override the Jump drive action:


List<IMyTerminalControl> controls;
MyAPIGateway.TerminalControls.GetControls<T>(out controls);

var jumpControl = controls.FirstOrDefault((x) => x.Id == "Jump") as IMyTerminalControlButton;
if (jumpControl != null)
{
    var oldAction = jumpControl.Action;
    jumpControl.Action = (b) =>
    {
        if (b.IsFTL())
            b.GameLogic.GetAs<FTLBase>().RequestJump();
        else
            oldAction(b);    };} 
And here's an example of creating a control:

var irisName = "Phoenix.Stargate.Iris";
var irisOnOff = MyAPIGateway.TerminalControls.CreateControl<IMyTerminalControlOnOffSwitch, IMyTerminalBlock>(irisName);
irisOnOff.Title = MyStringId.GetOrCompute("Iris/Shield");
irisOnOff.OnText = MyStringId.GetOrCompute("On"); ;
irisOnOff.OffText = MyStringId.GetOrCompute("Off"); ;
irisOnOff.Visible = (b) => b.GetGateType() == GateType.Stargate;
irisOnOff.Enabled = (b) => b.GetGateType() == GateType.Stargate && b.IsFunctional;
irisOnOff.Setter = (b, v) => MessageUtils.SendMessageToServer(new MessageIris() { Entity = b.EntityId, Activate = v });
irisOnOff.Getter = (b) => (b.GameLogic.GetAs<Stargate>()?.m_gateData?.IrisActive).GetValueOrDefault();
MyAPIGateway.TerminalControls.AddControl<IMyTerminalBlock>(irisOnOff);
They both should work now.

photo
1

Hi guys,


is it already fixed?

photo
1

yes, is fixed on my side.

photo
1

Thanks! :)

photo