BlueMond

Reactor Control (OC)

Jun 14th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. local components = require("component")
  2.  
  3. local reactor = components.reactor
  4.  
  5. local cooldown = false
  6. local max = .95
  7. local min = .5
  8.  
  9. reactor.setActive(true)
  10.  
  11. while true do
  12.     --find the deviation from maximum power
  13.     local deviation = reactor.getEnergyStored() / 10000000
  14.  
  15.     if not cooldown && deviation >= max then
  16.         cooldown = true
  17.         reactor.setActive(false)
  18.     end
  19.  
  20.     end
  21.  
  22.     if cooldown && deviation <= min then
  23.         cooldown = false
  24.         reactor.setActive(true)
  25.     end
  26.  
  27. end
Add Comment
Please, Sign In to add comment