Advertisement
MTM123

Untitled

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