Advertisement
Guest User

menu

a guest
Jan 23rd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. -- ****************************************************** --
  2. -- ****************************************************** --
  3. -- **             - MineNet ControlPanel -             ** --
  4. -- **                   Version: 0.1                   ** --
  5. -- **                                                  ** --
  6. -- **               Written by JustinVDM               ** --
  7. -- **                                                  ** --
  8. -- ****************************************************** --
  9. -- ****************************************************** --
  10.  
  11. -- ************ Some info about this program ************ --
  12. -- **                                                  ** --
  13. -- **     For this program to work you will need       ** --
  14. -- **  You will need TouchPoint API Written by: Lyqyd  ** --
  15. -- **                                                  ** --
  16. -- **    This program is still a work in progress!     ** --
  17. -- **                                                  ** --
  18. -- ****************************************************** --
  19.  
  20. --Loads API
  21. os.loadAPI("touch")
  22.  
  23. --Defines the pages
  24. local page1 = touch.new("top")
  25. local page2 = touch.new("top")
  26.  
  27. --Variable that stores the pages
  28. local t
  29.  
  30. function mainMenu()
  31.     t = page1
  32.     t:draw()
  33. end
  34.  
  35. function infoMenu()
  36.     t = page2
  37.     t:draw()
  38. end
  39.  
  40. --This function allows the lights to be turned on
  41. function lightB()
  42.     page1:toggleButton("Lights")
  43.         rs.setOutput("right", not rs.getOutput("right"))
  44. end
  45.  
  46. function callButton(name)
  47.         if t.buttonList[name].func ~= nil then
  48.            t.buttonList[name].func()
  49.     end
  50. end
  51.  
  52. --Adds the buttons
  53. do
  54.     page1:add("Main Menu", nil, 7,1,23,5, colors.black, colors.black)
  55.     page1:add("Lights", lightB, 7,6,24,8)
  56.     page1:add("Info", infoMenu, 7,10,24,12)
  57.  
  58.     page2:add("Info Menu", nil, 7,1,24,5, colors.black, colors.black)
  59.     page2:add("Reactor Info", reactorInfo, 7,6,24,8)
  60.     page2:add("Power Info", powerInfo, 7,10,24,12)
  61.     page2:add("Back", mainMenu, 7,14,24,16)
  62. end
  63.  
  64. mainMenu()
  65.  
  66. while true do
  67.     local event, p1 = t:handleEvents(os.pullEvent())
  68.     if event == "button_click" then
  69.         callButton(p1)
  70.     end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement