Stormworks: Build and Rescue

Stormworks: Build and Rescue

DanDanAttack Mar 28, 2020 @ 5:07pm
Lua Question on Boolean
Hey guys so I had a question about Boolean in Lua. I have a script that has indicator lights. I want those lights to turn on when a Boolean input is on. Example I have a rectange that indicates if my engine is on and I want a filled rectangle inside of it when my engine is turned on. How would I write that?
< >
Showing 1-1 of 1 comments
DaMarkiM Mar 30, 2020 @ 8:37pm 
Hoy.

its quite simple.
-add an on/off input to your chip that connects to whatever part you want to provide the input (for example the engine on/off toggle. note however that for this case of an engine being on/off you should rather check whether its rps is within the stall limit)
-inside the chips logic connect that on/off signal to a composite write and choose a channel
-connect that composite to your lua script
-get the boolean value from the composite signal with the input.getBool(channelnumber)
-you can now use that boolean value inside your script. if you want to draw a filled rectangle do a simple if booleanname==true then screen.drawRectF() end

of course the opposite is also true. you can export any boolean by doing output.setBool(), do a composite read and hook that up to a logical output.
< >
Showing 1-1 of 1 comments
Per page: 1530 50

Date Posted: Mar 28, 2020 @ 5:07pm
Posts: 1