Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local gpu = component.gpu
- local redstone = component.redstone
- local sides = require("sides")
- gpu.setResolution(80,25)
- local gui = require("gui")
- local event = require("event")
- gui.checkVersion(2,5)
- local prgName = "Toggler"
- local version = "v1.0"
- local state = false
- local function onoff_btn_callback(guiID, buttonID)
- if state == false then
- state = true
- redstone.setOutput(sides.right, 15)
- updateLabel(true)
- else
- state = false
- redstone.setOutput(sides.right, 0)
- updateLabel(false)
- end
- end
- local function exitButtonCallback(guiID, id)
- local result = gui.getYesNo("", "Do you really want to exit?", "")
- if result == true then
- gui.exit()
- end
- gui.displayGui(mainGui)
- refresh()
- end
- -- End: Callbacks
- -- Begin: Menu definitions
- mainGui = gui.newGui(1, 2, 79, 23, true)
- on_off = gui.newButton(mainGui, 35, 12, "On/Off", onoff_btn_callback)
- label_0 = gui.newLabel(mainGui, 33, 10, "Currently on", 0xff00, 0x0, 7)
- exitButton = gui.newButton(mainGui, 73, 23, "exit", exitButtonCallback)
- -- End: Menu definitions
- local function updateLabel(state)
- if state == true then
- gui.setText(mainGui, label_0, "Currently on", true)
- gui.setBackground(mainGui, label_0, 0x00ff00)
- else
- gui.setText(mainGui, label_0, "Currently off", true)
- gui.setBackground(mainGui, label_0, 0x0000ff)
- end
- end
- gui.clearScreen()
- gui.setTop("noname")
- gui.setBottom("Made with Visual Gui v0.1a and Gui library v2.5")
- -- Main loop
- while true do
- gui.runGui(mainGui)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement