Advertisement
Guest User

menu

a guest
Jan 23rd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.95 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. --Calls The reactor
  24. local reactor = peripheral.wrap("BigReactors-Reactor_0")
  25.  
  26. --Defines the pages
  27. local page1 = touch.new("top")
  28. local page2 = touch.new("top")
  29. local page3 = touch.new("top")
  30. local page4 = touch.new("top")
  31.  
  32. --Variable that stores the pages
  33. local t
  34.  
  35. --Reactor variables
  36. local maxPower = 0
  37. local powerStored = reactor.getEnergyStored
  38. local fuelStored = reactor.getFuelAmount
  39. local temp = reactor.getTemperature
  40.  
  41. --Just some function that wil allow switching between pages
  42. function mainMenu()
  43.     t = page1
  44.     t:draw()
  45. end
  46.  
  47. function infoMenu()
  48.     t = page2
  49.     t:draw()
  50. end
  51.  
  52. function reactorControls()
  53.   t = page3
  54.   t:draw()
  55. end
  56.  
  57. function infoReactor()
  58.   t = page4
  59.   t:draw()
  60. end
  61.  
  62. --Function that wil turn reactor on and off
  63. function toggleReactor()
  64.     if reactor.getActive == true then
  65.         page3:toggleButton("Turn On/Off")
  66.     else reactor.setActive = true
  67.  
  68.     end
  69. end
  70.  
  71. --This function allows the lights to be turned on
  72. function lightB()
  73.     page1:toggleButton("Lights")
  74.         rs.setOutput("right", not rs.getOutput("right"))
  75. end
  76.  
  77. function callButton(name)
  78.         if t.buttonList[name].func ~= nil then
  79.            t.buttonList[name].func()
  80.     end
  81. end
  82.  
  83. --Adds the buttons
  84. do
  85.     page1:add("Main Menu", nil, 7,1,23,5, colors.black, colors.black)
  86.     page1:add("Lights", lightB, 7,6,24,8)
  87.     page1:add("Reactor Controls", reactorControls, 7,10,24,12)
  88.     page1:add("Info", infoMenu, 7,14,24,16)
  89.  
  90.     page2:add("Info Menu", nil, 7,1,24,5, colors.black, colors.black)
  91.     page2:add("Reactor Info", infoReactor, 7,6,24,8)
  92.     page2:add("Back", mainMenu, 7,10,24,12)
  93.  
  94.     page3:add("Reactor Controls", nil, 7,1,24,5, colors.black, colors.black)
  95.     page3:add("Turn On/Off", toggleReactor, 7,6,24,8)
  96.     page3:add("Back", mainMenu, 7,10,24,12)
  97. end
  98.  
  99. mainMenu()
  100.  
  101. while true do
  102.     local event, p1 = t:handleEvents(os.pullEvent())
  103.     if event == "button_click" then
  104.         callButton(p1)
  105.     end
  106. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement