Advertisement
MTM123

toggler

Oct 29th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. local component = require("component")
  2. local gpu = component.gpu
  3. local redstone = component.redstone
  4. gpu.setResolution(80,25)
  5. local gui = require("gui")
  6. local event = require("event")
  7.  
  8. gui.checkVersion(2,5)
  9.  
  10. local prgName = "Toggler"
  11. local version = "v1.0"
  12.  
  13. local state = false
  14. local function onoff_btn_callback(guiID, buttonID)
  15. if state == false then
  16. state = true
  17. redstone.setOutput(sides.right, 15)
  18. else
  19. state = false
  20. redstone.setOutput(sides.right, 0)
  21. end
  22. end
  23.  
  24. local function exitButtonCallback(guiID, id)
  25. local result = gui.getYesNo("", "Do you really want to exit?", "")
  26. if result == true then
  27. gui.exit()
  28. end
  29. gui.displayGui(mainGui)
  30. refresh()
  31. end
  32. -- End: Callbacks
  33.  
  34. -- Begin: Menu definitions
  35. mainGui = gui.newGui(1, 2, 79, 23, true)
  36. on_off = gui.newButton(mainGui, 35, 12, "On/Off", onoff_btn_callback)
  37. label_0 = gui.newLabel(mainGui, 33, 10, "Currently on", 0xff00, 0x0, 7)
  38. exitButton = gui.newButton(mainGui, 73, 23, "exit", exitButtonCallback)
  39. -- End: Menu definitions
  40.  
  41. gui.clearScreen()
  42. gui.setTop("noname")
  43. gui.setBottom("Made with Visual Gui v0.1a and Gui library v2.5")
  44.  
  45. -- Main loop
  46. while true do
  47. gui.runGui(mainGui)
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement