Space Engineers

Space Engineers

View Stats:
Programming blocks for noobs
Hello I dont know much about computers. I have been playing SE for a while now and I'm to the point I need to use the programmable Blocks. When I look in the workshop under scripts there are just more mods (found a few scripts). Can anyone guide me to like a programmable block for idiots guide? thanks in advance!
< >
Showing 1-5 of 5 comments
Jota Oct 15, 2015 @ 5:16pm 
I wrote a programming guide back when programming blocks were introduced in the game, it's oriented towards beginners so it might help you:
http://steamcommunity.com/sharedfiles/filedetails/?id=368970814
jetsetsoaper Oct 15, 2015 @ 6:11pm 
hey, ive been programming on and off for a while, but when i started in SE the most confusing thing for me was making the code interact with blocks.

heres a simple program that hopefully explains this:


void Main() { var door1 = GridTerminalSystem.GetBlockWithName("Door") as IMyDoorBlock; //make a variable for ur door, // (THE BLOCK HAS TO BE NAMED "Door") var light1 = GridTerminalSystem.GetBlockWithName("Interior Light") as IMyInteriorLight; //same with the light if (door1.Open == true) //if the door is open { light1.GetActionWithName("OnOff_On").Apply(light1); //turn on light } }

heres the list of blocks and what type of input, and output they can give/recieve:

http://steamcommunity.com/sharedfiles/filedetails/?id=360966557

the whole trick is learning the parts of the line of code.

"var" means to make a variable, "door1" was a name i made up, to define the door (this can be any name)

"GridTerminalSystem" not really sure lol, but u need it

"GetBlockWithName" searchs ur control panel for a block that has the same name. ( the name of the block can be changed in control panel, so make sure everything is names correctly) (also its case sensitive)

and the "as IMy..." part defines that it is of that type. ( refer to the link below to find the correct names for each block type)

"door1.Open" the first part is the name we defined it "door1" this can be anything u want as well, as long as the names match. and the "Open" part is another part of code u cant see (specific to doors), that basicly returns a boolean variable (ie. true or false, 1 or 0) to tell if the door is open.

then my "if" statement says, "if the variable returned from Open is true, then do the code inside the { }'s

lastly, the "GetActionWithName" part looks for different commands the block can do, these are the same commands u can drag to ur toolbar in game, from the G menu. but they are not all spelt the same (refer to the link below to see all the actions a block can use)

our example turns the light on, using the action "OnOff_On" that part is confusing i guess cuz how the names the action. ie: to turn on is "OnOff_On", to turn off is "OnOff_Off", and to just toggle between 1 or the other is "OnOff"

then the "Apply" part just makes it run the action u picked.



goodluck, and have fun!

ps i wrote this in steam, so its sloppy, and my SE crashes when i alt tab. so it might be wrong. but it should work
Last edited by jetsetsoaper; Oct 15, 2015 @ 6:12pm
jetsetsoaper Oct 15, 2015 @ 6:18pm 
its important to note that this program will only run once, and then stop.

in other words, if u run this program, THEN open the door, it will NOT turn the light on.

it will only look to see if the door is open, then turn the light on if the doors open, then close.

u need to use a timer block, set the timer to 1 or 2 seconds, set the timer action to "run" the "program block", and then click "start" on the timer.

this will run the program over and over every 1 or 2 seconds, allowing the light to turn on when u open the door
zooxanthellaeh2o Oct 16, 2015 @ 8:56am 
this is great info guys thank you both so much for taking the time to explain. maybe there is hope for noobs! ill keep you updated =)
The Haney Oct 16, 2015 @ 12:12pm 
Honestly I just get the scripts I want from the workshop. Most of em have all the relevant info in the actual script itself, which is crazy awesome. I know, and care to know, zero coding and my ship is wired up all sorts of nuts.
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: Oct 15, 2015 @ 5:07pm
Posts: 5