Advertisement
eforen

Reactor Controller - Core

Nov 27th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. -- To install use "pastebin run 6sy87Yin"
  2. -- http://pastebin.com/QGfvG1eU | Reactor Controller - Core | By Eforen (Ariel Lothlorien)
  3.  
  4. cell = peripheral.wrap("cofh_thermalexpansion_energycell_1")
  5. reactor = peripheral.wrap("BigReactors-Reactor_1")
  6. -- net = peripheral.wrap("top")
  7.  
  8. --methods = net.callRemote("cofh_thermalexpansion_energycell_1", "getEnergyStored", "unknown")
  9.  
  10. --bottom = 0.25
  11. --top = 0.95
  12.  
  13. bottom = 0.02
  14. top = 0.10
  15.  
  16. event, par1 = "run", "start"
  17. timer = os.startTimer(1)
  18.  
  19. while(event ~= "exit") do
  20.     event, par1, par2, par3, par4, par5 = os.pullEvent()
  21.     if(event == "key") then
  22.         if par1 == 16 then
  23.             os.queueEvent("exit")
  24.         end
  25.         if par1 == 19 then --R
  26.             os.reboot()
  27.         end
  28.         if par1 == 31 then --S
  29.             os.shutdown()
  30.         end
  31.     elseif(event == "timer") then
  32.         timer = os.startTimer(1)
  33.         --stored = cell.getEnergyStored("unknown")
  34.         --max = cell.getMaxEnergyStored("unknown")
  35.         stored = reactor.getEnergyStored()
  36.         max = 10000000
  37.         print(tostring(stored).."/"..tostring(max).."="..tostring(stored/max).."%")
  38.         if(stored/max > top and reactor.getActive())then
  39.             print("Turning Off Reactor...")
  40.             reactor.setActive(false)
  41.         elseif(stored/max < bottom and reactor.getActive()==false)then
  42.             print("Turning On Reactor...")
  43.             reactor.setActive(true)
  44.         end
  45.     end
  46. end
  47.  
  48. if (par1 ~= nil) then
  49.     print(par1)
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement