Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This script expects the basalt lib directory to be one directory above it (it should live in the startup directory in the root of the computer)
- local basalt = require("/basalt") --UI Library for cc tweaked
- -- Get a reference to the monitor
- local monitor = peripheral.find("monitor")
- -- Or specific side: peripheral.wrap("right")
- -- Create frame for monitor
- local monitorFrame = basalt.createFrame():setTerm(monitor) -- :setTerm is the important method here
- local function get_light_status()
- if redstone.getOutput("bottom") == true then
- light_status = "On"
- bg_color = colors.green
- else
- light_status = "Off"
- bg_color = colors.gray
- end
- end
- get_light_status()
- -- Add elements like normal
- my_button = monitorFrame:addButton()
- :setText(light_status)
- :setWidth(24)
- :setPosition(2, 2)
- :setBackground(bg_color)
- :onClick(function()
- -- Toggle redstone output on bottom of computer when clicked
- redstone.setOutput("bottom", not redstone.getOutput("bottom"))
- get_light_status()
- my_button:setBackground(bg_color)
- my_button:setText(light_status)
- end)
- -- Start Basalt
- basalt.run()
Advertisement
Add Comment
Please, Sign In to add comment