Stormworks: Build and Rescue

Stormworks: Build and Rescue

Toggleable boutons and style [On/Off]
7 kommentarer
lokefs3000 1. jan. 2020 kl. 23:20 
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 kl. 23:19 
heres the script if you want to help
lokefs3000 1. jan. 2020 kl. 23:18 
can anyone help me with this lua script i cant figure out whats wrong
ToothpasteMain 22. aug. 2019 kl. 15:11 
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. maj 2019 kl. 9:40 
nice! does this work with the 1x1 monitor?
Viscy 19. maj 2019 kl. 3:04 
Thank you very much <3

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