Advertisement
Guest User

reactor

a guest
Apr 18th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. local reactor = peripheral.wrap("back")
  2. local cell = peripheral.wrap("right")
  3. local mon = peripheral.wrap("left")
  4. local max = cell.getMaxEnergyStored("right")
  5. local Lthreshold = max / 2
  6. local Uthreshold = max - 5000
  7. local str = "off"
  8.  
  9. local function getPower()
  10.   local energy = cell.getEnergyStored("right")
  11.   return energy
  12. end
  13.  
  14. while true do
  15.   if(getPower() > Uthreshold) then
  16.     reactor.setActive("false")
  17.     str = "off"
  18.   elseif(getPower() < Lthreshold) then
  19.     reactor.setActive("true")
  20.     str = "on"
  21.   end
  22.  
  23.   mon.clear()
  24.   mon.setCursorPos(0,0)
  25.   mon.write(str)
  26.   print(str)
  27.  
  28.   os.sleep(10)
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement