Stormworks: Build and Rescue

Stormworks: Build and Rescue

Ei tarpeeksi arvosteluja
Toggleable boutons and style [On/Off]
   
Palkinto
Lisää suosikkeihin
Lisätty suosikkeihin
Poista suosikeista
Microcontrollers: Cockpit, Microcontroller
Tunnisteet: v0.7.4
Tiedostokoko
Julkaistu
Päivitetty
32.389 KB
18.5.2019 klo 6.28
18.5.2019 klo 7.06
2 muutosilmoitusta ( näytä )

Tilaa ladataksesi
Toggleable boutons and style [On/Off]

Kuvaus
Presentation

This microcontroller allow you to create a 2x2 (by default) maximum 6 toggleables buttons screen.
You can use a bigger screen, but don't forget to set correct values for the " w " in the sub-table " pos " of each buttons.

Settings

- Change the background color :
globalBackGroundColor = function() screen.setColor(89, 89, 89) end

{"btn_1", display=true, pos={x=1, y=2, w=62, h=9}, borderAndTextColor=function() screen.setColor(0, 0, 0) end, backgroundColor=function() screen.setColor(255, 255, 255) end, text="Button 1", outputChannel=1, defaultState=false}

Field
Description
First field
the first field ( "btn_1" in this exemple) is the name of the button, not used anywhere. just a memo for you. If you don't use it, you can remove the field and don't forget the comma.
display
This field show or hide the button. For not used buttons for exemple.
pos
This field is the position from the top-left corner of the screen. In order : x, y, width, height
borderAndTextColor
This field define the color of borders and text. When the button is toggled, the borders and text take the background color.
backgroundColor
This field define the color of the button background. When the button is toggled, the background take the borders and text color.
text
This field define the displayed text of the button.
channel
Define the exit channel of the signal with the exit composite signal. If you change it, don't forget to update module after the LUA module.
defaultState
Define the default state when the microcontroller is initialized.
7 kommenttia
lokefs3000 1.1.2020 klo 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.1.2020 klo 23.19 
heres the script if you want to help
lokefs3000 1.1.2020 klo 23.18 
can anyone help me with this lua script i cant figure out whats wrong
ToothpasteMain 22.8.2019 klo 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.5.2019 klo 9.40 
nice! does this work with the 1x1 monitor?
Viscy 19.5.2019 klo 3.04 
Thank you very much <3

Thumbs Up!
Great Work
lolo 18.5.2019 klo 8.25 
So nice, your eplanation of the script is a big plus ! Thx