SHARE
TWEET

NC Fission Reactor control

Max_Gino Jan 11th, 2019 (edited) 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top