Stormworks: Build and Rescue

Stormworks: Build and Rescue

Toggleable boutons and style [On/Off]
7 Comments
lokefs3000 1 Jan, 2020 @ 11:20pm 
function onTick()
-- Read the touchscreen data from the script's composite input
inputX = input.getNumber(3)
inputY = input.getNumber(4)
isPressed = input.getBool(1)
isPressed = input.getBool(2)

-- Check if the player is pressing the rectangle at (10, 10) with width and height of 20px
isPressingRectangle = isPressed and isPointInRectangle(inputX, inputY, 10, 10, 20, 20)
isPressingRectangle = isPressed and isPointInRectangle(inputX, inputY, 20, 10, 20, 20)

-- Set the composite output, on/off channel 1
output.setBool(1, isPressingRectangle)
end

height rectH
function isPointInRectangle(x, y, rectX, rectY, rectW, rectH)
return x > rectX and y > rectY and x < rectX+rectW and y < rectY+rectH
end

function onDraw()

if isPressingRectangle then
screen.drawRectF(10, 10, 20, 20)
else
screen.drawRect(10, 10, 20, 20)

if isPressingRectangle then
screen.drawRectF(10, 10, 20, 20)
else
screen.drawRect(20, 10, 20, 20)


end
end
lokefs3000 1 Jan, 2020 @ 11:19pm 
heres the script if you want to help
lokefs3000 1 Jan, 2020 @ 11:18pm 
can anyone help me with this lua script i cant figure out whats wrong
ToothpasteMain 22 Aug, 2019 @ 3:11pm 
Very nice and super easy to use. Could you make a microcontroller where only one button can be enabled at a time; where if one button is pressed, any other enabled buttons would be toggled off?
pr0c3lla 20 May, 2019 @ 9:40am 
nice! does this work with the 1x1 monitor?
Viscy 19 May, 2019 @ 3:04am 
Thank you very much <3

Thumbs Up!
Great Work
lolo 18 May, 2019 @ 8:25am 
So nice, your eplanation of the script is a big plus ! Thx