Guest User

program

a guest
Jan 3rd, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.87 KB | None | 0 0
  1. os.loadAPI("button")
  2. monitor = peripheral.wrap("bottom")
  3. monitor.clear()
  4.  
  5.  
  6. reactor = peripheral.wrap("BigReactors-Reactor_4")
  7. turbine = peripheral.wrap("BigReactors-Turbine_3")
  8.  
  9.  
  10. reactor.setActive(false)
  11. turbine.setActive(false)
  12.  
  13. function fillTable()
  14.  
  15.   button.setTable("Turbine", toggleTurbine, 8, 16, 3, 5)
  16.   button.setTable("Reactor", toggleReactor, 24, 32, 3, 5)
  17.   button.setTable("+", increaseSteam, 8, 12, 6, 8)
  18.   button.setTable("-", decreaseSteam, 12, 16, 6, 8)
  19.  
  20.   button.screen()
  21. end
  22.  
  23. function toggleReactor()
  24.   button.toggleButton("Reactor")
  25.   reactor.setActive(not reactor.getActive())
  26. end
  27.  
  28. function toggleTurbine()
  29.   button.toggleButton("Turbine")
  30.   turbine.setActive(not turbine.getActive())
  31. end
  32.  
  33. function increaseSteam()
  34.   if turbine.getFluidFlowRateMax() <= 1990 then
  35.     turbine.setFluidFlowRateMax(turbine.getFluidFlowRateMax() + 10)
  36.     button.flash("+")
  37.   end  
  38. end  
  39.  
  40. function decreaseSteam()
  41.   if turbine.getFluidFlowRateMax() >= 10 then
  42.     turbine.setFluidFlowRateMax(turbine.getFluidFlowRateMax() - 10)
  43.     button.flash("-")
  44.   end  
  45. end    
  46.  
  47. function getClick()
  48.   event, side, x, y = os.pullEvent("monitor_touch")
  49.   button.checkxy(x, y)
  50. end
  51.  
  52. function dataReadout()  
  53.     monitor.setCursorPos(8,10)
  54.     monitor.write("Rotor Speed:")
  55.     monitor.setCursorPos(8,11)
  56.     monitor.write(turbine.getRotorSpeed())
  57.     monitor.setCursorPos(8,12)
  58.     monitor.write("Fluid Flow Rate Max:")
  59.     monitor.setCursorPos(8,13)
  60.     monitor.write(turbine.getFluidFlowRateMax())
  61. end
  62.  
  63. function manual()
  64.   local timer=os.startTimer(1)
  65.   while true do
  66.     timer=os.startTimer(1)
  67.     local event, par1, par2, par3 = os.pullEvent()
  68.     if event=="timer" then
  69.       dataReadout()
  70.     elseif event=="monitor_touch" then
  71.       button.checkxy(par2, par3)
  72.     end
  73.   end
  74. end
  75.  
  76. fillTable()
  77. button.heading("Reactor and Turbine Control")
  78. manual()
Advertisement
Add Comment
Please, Sign In to add comment