Space Engineers

Space Engineers

Projections To Assembler
MiniKiwi Aug 2, 2019 @ 8:48pm
Allow Automation of "Send To Assembler" Through Actions and Prog Blocks (With Code)
Hey there,

I've been toying around with this for a bit today looking for a way to make this work with actions from the timer blocks or action calls from the programmable block and I've finally got it working. As a responsible developer, I don't want to rip your work off, so I'm submitting it to you as a feature enhancement that you can include.

I've only had to add two snippets of code - the main lifting work is still done by your original code, but because those methods aren't public, the only ways to access them are to either make them public, or add this stuff inside your script.

In UpdateBeforeSimulation()
// Create the actions IMyTerminalAction actionAddAll = MyAPIGateway.TerminalControls.CreateAction<IMyProjector>("SendGridToAssembler"); IMyTerminalAction actionAddMissing = MyAPIGateway.TerminalControls.CreateAction<IMyProjector>("SendMissingToAssembler"); // Name the actions actionAddAll.Name = new StringBuilder("Send All To Assembler"); actionAddMissing.Name = new StringBuilder("Send Missing To Assembler"); // Set the action text actionAddAll.Writer = IconTextAll; actionAddMissing.Writer = IconTextMissing; // Set the icons actionAddAll.Icon = $"{ModContext.ModPath}\\Textures/GUI/Icons/Actions/SendAll.dds"; actionAddMissing.Icon = $"{ModContext.ModPath}\\Textures/GUI/Icons/Actions/SendMissing.dds"; // Bind the actions actionAddAll.Action = ProjectorAction; actionAddMissing.Action = ProjectorActionB; // Add the actions to projectors MyAPIGateway.TerminalControls.AddAction<IMyProjector>( actionAddAll ); MyAPIGateway.TerminalControls.AddAction<IMyProjector>( actionAddMissing );

and two separate methods:
void IconTextAll( IMyTerminalBlock block, StringBuilder sbuilder ) { sbuilder.Append("All"); } void IconTextMissing( IMyTerminalBlock block, StringBuilder sbuilder ) { sbuilder.Append("Missing"); }

I also created two simple action icon textures - SendAll.dds and SendMissing.dds stored under Textures/GUI/Icons/Actions/ - If you're interested in these, I can provide them too although they're nothing special.


I hope you will find this useful, and consider adding it in. This would give us the possibility to create self replicating structures that only build the components they need.

Thanks for the amazing plugin anyway!
(Hopefully the formatting has worked - I've never made a Steam discussion post before)
Edit: Culled unneeded code spacing
Last edited by MiniKiwi; Aug 2, 2019 @ 8:49pm
< >
Showing 1-8 of 8 comments
Waylander  [developer] Nov 30, 2019 @ 12:15pm 
Would you be able to send to a specific assembler using this modification? Programmatically or with timers I mean
Last edited by Waylander; Nov 30, 2019 @ 12:30pm
MiniKiwi Dec 2, 2019 @ 12:15pm 
It's been quite some time since I actually looked at this - I am not a Space Engineers modder, I'm just familiar with C# and had a desire to tweak it like this for some reason that I don't remember.
In theory, if the mod itself supported specifying the assembler to use, then yes this would work as it uses the original functions defined by the mod.
But I don't think this mod does allow you to select the specific assembler to send the job to does it?
Waylander  [developer] Dec 3, 2019 @ 12:16pm 
It does, there is a list where you can select the assembler you want to send the items to.
MiniKiwi Dec 4, 2019 @ 6:55pm 
Well then yes that would definitely work - this modification behaves exactly the same as if you had pressed the buttons in the UI
Waylander  [developer] Dec 6, 2019 @ 8:58am 
I was thinking about timer blocks and toolbars. It will probably be necessary to pass the name of the assembler in the same way that you can pass an argument to a programmable block.
Waylander  [developer] Apr 25, 2020 @ 4:23pm 
@MiniMule, do you still have those icons laying around? I'm currently adding this functionality to the mod and I could add them.
Waylander  [developer] Jan 9, 2021 @ 2:42pm 
Seems I forgot to mention it but this is now possible using both actions in the toolbar and the programmable block.

For the toolbar, drag the projector to the toolbar and choose AssembleMissing or AssembleAll.

Programmable block example:
projector.ApplyAction("AssembleAll"); projector.ApplyAction("AssembleMissing");

In both cases the last assembler selected in the terminal will be used.
< >
Showing 1-8 of 8 comments
Per page: 1530 50