Advertisement
jc2xs

Reactor Controller

May 3rd, 2015
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. -- Reactor = BigReactors-Reactors_0
  2. cbtxt = "tile_blockcapacitorbank_name_0"
  3. -- Computer = computer_0
  4. cb = peripheral.wrap(cbtxt)
  5. r = peripheral.wrap("back")
  6.  
  7. -- Initially turn the reactor off on reboot of computer
  8. r.setActive(false)
  9. rs = "off"  -- current reactor state - used to display only
  10.  
  11. -- Limits
  12. ul = 95  -- upper limit
  13. ll = 50  -- lower limit
  14.  
  15. cbmax = cb.getMaxEnergyStored()
  16. print (cbmax)
  17. while true do
  18.   cbcur = cb.getEnergyStored()
  19.   cbper = 100 * cbcur/cbmax
  20.   if cbper > ul then    -- if above upper limit then reactor off
  21.     r.setActive(false)
  22.     rs = "off"
  23.   end
  24.   if cbper < ll then    -- if below lower limit then reactor on
  25.     r.setActive(true)
  26.     rs = "on"
  27.   end    
  28.   print(cbcur .. " of " .. cbmax .. "    " .. cbper .. "% - Reactor is " .. rs)
  29.   sleep(10)
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement