Stormworks: Build and Rescue

Stormworks: Build and Rescue

Toggleable boutons and style [On/Off]
7 条留言
lokefs3000 2020 年 1 月 1 日 下午 11: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 2020 年 1 月 1 日 下午 11:19 
heres the script if you want to help
lokefs3000 2020 年 1 月 1 日 下午 11:18 
can anyone help me with this lua script i cant figure out whats wrong
ToothpasteMain 2019 年 8 月 22 日 下午 3: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 2019 年 5 月 20 日 上午 9:40 
nice! does this work with the 1x1 monitor?
Viscy 2019 年 5 月 19 日 上午 3:04 
Thank you very much <3

Thumbs Up!
Great Work
lolo 2019 年 5 月 18 日 上午 8:25 
So nice, your eplanation of the script is a big plus ! Thx