Advertisement
Xylem_Gaming

2 Reactor Controller

Feb 20th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. big1 = peripheral.wrap("BigReactors_Reactor-1")
  2. big2 = peripheral.wrap("BigReactors_Reactor-2")
  3.  
  4. mon = peripheral.find("monitor")
  5.  
  6. if mon == nil then
  7.     mon = term
  8. end
  9.  
  10. act = 1000000 -- 1 mil
  11. des = 106000000 -- 106 mil
  12.  
  13. function main()
  14. while true do
  15.     sleep(1)
  16.     val = cap.getEnergyStored()
  17.     cur = math.floor(val*106)
  18.  
  19.     mon.clear()
  20.     mon.setCursorPos(1,1)
  21.     actv1 = big1.getActive()
  22.     mon.write("Reactor 1 :")
  23.     if actv1 == true then
  24.         mon.setTextColour(colour.green)
  25.         mon.write("Online")
  26.     else
  27.         mon.setTextColour(colour.red)
  28.         mon.write("Offline")
  29.     end
  30.     mon.setTextColour(colours.white)
  31.     mon.setCursorPos(1,3)
  32.     mon.write("Tick Rate: "..big1.getEnergyProducedLastTick)
  33.     mon.setCursorPos(1,5)
  34.     actv2 = big2.getActive()
  35.     mon.write("Reactor 2 :")
  36.     if actv2 == true then
  37.         mon.setTextColour(colour.green)
  38.         mon.write("Online")
  39.     else
  40.         mon.setTextColour(colour.red)
  41.         mon.write("Offline")
  42.     end
  43.  
  44.     if cur < 50000000 then
  45.         big1.setActive(true)
  46.         big2.setActive(true)
  47.     elseif cur >= 50000000 and trig == false then
  48.         big1.setActive(false)
  49.         big2.setActive(false)
  50.     end
  51. end
  52. end
  53.  
  54. function redstone()
  55.     while true do
  56.         sleep(1)
  57.         if redstone.getInput("left") == false then
  58.             trig = false
  59.         else
  60.             trig = true
  61.         end
  62.     end
  63. end
  64.  
  65. function controll()
  66.     term.clear()
  67.     term.setCursorPos(1,1)
  68.     print("Type 'Stop' to stop")
  69.     input = io.read()
  70.     sinput = string.lower(input)
  71. end
  72.  
  73. function read()
  74.     repeat controll()
  75.     until sinput == "stop"
  76. end
  77.  
  78. parellel.waitForAny(read,main,redstone)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement