Advertisement
Xylem_Gaming

Menu

Mar 27th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.41 KB | None | 0 0
  1. --[[
  2. This is the variables for the reactor function
  3. ]]
  4.  
  5. mon = peripheral.find("monitor")
  6. if mon ~= nil then
  7.   local term = mon
  8. end
  9.  
  10. reactor1 = peripheral.wrap("BigReactors-Reactor_2")
  11. reactor2 = peripheral.wrap("")
  12. reactor3 = peripheral.wrap("")
  13. reactor4 = peripheral.wrap("")
  14.  
  15. --[[
  16. Variables for the main program, please do not touch
  17. ]]
  18. x,y = term.getSize()
  19. running = false
  20. index = 1
  21.  
  22. default = {
  23. background = "black",
  24. textC = "white"
  25. }
  26.  
  27. button = {
  28. button1 = {text = "Back",bx = 1, by = y},
  29. button2 = {text = "Select", bx = math.floor((x/2)-(string.len("Select")/2)), by = y},
  30. button3 = {text = "Next",bx = x-string.len("Next")+1, by = y}
  31. }
  32. buttonSize = table.getn(button)
  33. local function drawButton(state1,state2,state3,colour)
  34.   if colour == nil then colour = "red" end
  35.   term.setBackgroundColour(colours[colour])
  36.   if state1 then
  37.     term.setCursorPos(button.button1.bx,button.button1.by)
  38.     term.write(button.button1.text)
  39.   end
  40.   term.setCursorPos(1,1)
  41.   term.setBackgroundColour(colours[default.background])
  42.   term.setTextColour(colours.yellow)
  43.   term.write("Reactor: "..index)
  44.   term.setBackgroundColour(colours[colour])
  45.   term.setTextColour(colours[default.textC])
  46.   if state2 then
  47.     term.setCursorPos(button.button2.bx,button.button2.by)
  48.     term.write(button.button2.text)
  49.   end
  50.   if state3 then
  51.     term.setCursorPos(button.button3.bx,button.button3.by)
  52.     term.write(button.button3.text)
  53.   end
  54.   term.setBackgroundColour(colours[default.background])
  55. end
  56.  
  57. local function flashButton(b)
  58.   if b == 1 then drawButton(true,false,false,"green") end
  59.   if b == 2 then drawButton(false,true,false,"green") end
  60.   if b == 3 then drawButton(false,false,true,"green") end
  61.   sleep(0.25)
  62.   drawButton(true,true,true)
  63. end
  64.  
  65. local function clearScreen()
  66.   for i = 1,y-1 do
  67.     term.setCursorPos(1,i)
  68.     term.clearLine()
  69.   end
  70. end
  71.  
  72. term.clear()
  73.  
  74. local function printBar(x,y,val)
  75.   term.setCursorPos(x,y)
  76.   term.setBackgroundColour(colours.red)
  77.   for i = 1,25 do
  78.     print(" ")
  79.   end
  80.   term.setBackgroundColour(colours.green)
  81.   for i = 1,val do
  82.     print(" ")
  83.   end
  84.   term.setBackgroundColour(colours[default.background])
  85. end
  86.  
  87. function printReactor()
  88.   while running do
  89.   per1 = math.floor(((cur1/max)*100)/25)
  90.   term.setCursorPos(1,2)
  91.   term.write("RF Stored: ")
  92.   printBar(1+string.len("RF Stored: "),2,per1)
  93. end
  94. end
  95.  
  96. function gui()
  97. while running do
  98.   if index == 1 then
  99.     drawButton(false,true,true)
  100.   elseif
  101.     drawButton(true,true,false)
  102.   else
  103.     drawButton(true,true,true)
  104.   end
  105.   event, param1, param2, param3 = os.pullEvent()
  106.   if event == "mouse_click" then
  107.     if param2 >= button.button1.bx and param2 <= (button.button1.bx + #button.button1.text) and param3 == button.button1.by and index ~= 1 then
  108.       flashButton(1)
  109.       index = index - 1
  110.       clearScreen()
  111.     elseif param2 >= button.button2.bx and param2 <= (button.button2.bx + #button.button2.text) and param3 == button.button2.by then
  112.       flashButton(2)
  113.     elseif param2 >= button.button3.bx and param2 <= (button.button3.bx + #button.button3.text) and param3 == button.button3.by and index ~= 4 then
  114.       flashButton(3)
  115.       index = index + 1
  116.       clearScreen()
  117.     end
  118.   elseif event == "key" then
  119.     if param1 == keys.y then
  120.       running = false
  121.       shell.run("edit main")
  122.     end
  123.   end
  124.   term.setCursorPos(1,y)
  125.   term.clearLine()
  126. end
  127. end
  128.  
  129. parallel.waitForAny(gui,printReactor)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement