Advertisement
BlueMond

Reactor Cooldown

Jun 3rd, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. local reactor = peripheral.wrap("back")
  2.  
  3. local storeMin = .6
  4. local storeMax = .9
  5. local max = 10000000
  6.  
  7. local cooldown = false
  8.  
  9. while true do
  10.     os.sleep(1)
  11.     local stored = reactor.getEnergyStored()
  12.    
  13.     local test = stored/max
  14.    
  15.     --if reactor has gone over 90% capacity
  16.     if test >= storeMax then
  17.    
  18.         --check if in cooldown state
  19.         if not cooldown then
  20.             --set to cooldown and turn off
  21.             cooldown = true
  22.             reactor.setActive(false)
  23.         end
  24.    
  25.     --if reactor is depleated from cooldown
  26.     else
  27.         if test <= storeMin then
  28.    
  29.             --check if in cooldown
  30.             if cooldown then
  31.                 --take out of cooldown
  32.                 cooldown = false
  33.                 reactor.setActive(true)
  34.             end
  35.         end
  36.     end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement