Add Programmable Block APIs for Toolbar-style Actions
Many blocks have configurable actions that the player can configure them to cause another block on the grid to take some action (think button panels, air vents, and timer blocks, among others).
It would be great to have some way to set these actions from inside the script in the Programmable Block.
The use case I have in mind is a Programmable Block script that has many possible actions that the player can take, and I'd like to provide them with an easy way to set up button panels in order to execute them all. (It's a mining drone hub in my specific example, where the player can dispatch drones to various GPS coordinates or recall specific drones from whatever they are doing.)
The API on IMyButtonPanel allows the Programmable Block to set the button's names and, in the case of the sci-fi button panel, use IMyTextSurfaceProvider to set the values on the screens. But the player still has to set up the actions with all the right arguments, which is error prone and confusing.
Rather than add this support to IMyButtonPanel specifically, I'd say it would make sense to provide an API to access the action slots a given block has already, which the player has access to through the game. Another top-level interface that the existing blocks could implement would be great.
Something like this: (this is a very rough sketch, I'm happy for any specifics to change, this is just to get the idea of what I'm looking for)
struct MyBlockAction { public static MyBlockAction Empty; public IMyTerminalBlock BlockToApplyActionTo; public ITerminalAction Action; public bool IsEmpty(); } interface IMyActionBlock { int ActionCount { get; } void GetBlockActions(List<MyBlockAction> actions); void SetBlockAction(int actionIndex, IMyTerminalBlock blockToApplyActionTo, ITerminalAction action); }
More would probably need to be done with naming to disambiguate it from IMyTerminalBlock.GetActions, which seems to show up only the actions you can perform on the block in question from the Terminal in-game UI. I'm also assuming that I've correctly interpretted what ITerminalAction (the pre-existing type) represents ("an in-game action that a single block can take"), examples of which would include:
- Enable a block (make it draw power)
- Trigger a timer block
- Disconnect a connected Connector
- Run a Programmable Block (with an argument)
etc.
Basically, I would like to be able to access the functionality of the "Setup Actions" button from the in-game Terminal UI.
Replies have been locked on this page!