Advertisement
Max_Gino

NC Fission Reactor control

Jan 11th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local component = require("component")
  2. local reactor = component.nc_fission_reactor
  3.  
  4. function stop()
  5.     reactor.deactivate()
  6. end
  7.  
  8. function start()
  9.     reactor.activate()
  10. end
  11.  
  12. function getEnergy()
  13.     local max = reactor.getMaxEnergyStored()
  14.     local current = reactor.getEnergyStored()
  15.     local percent = math.ceil(100*current/max)
  16.     return percent
  17. end
  18.  
  19. while true do
  20.     local currentEnergy = getEnergy()
  21.     if currentEnergy >= 90 and reactor.isProcessing() then
  22.         stop()
  23.     elseif currentEnergy <= 25 and reactor.isProcessing() == false then
  24.         start()
  25.     end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement