OreSeur-

My Reactor Code 1

Jan 14th, 2021 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. --the total size of the buffer
  2. local TOTAL_MAX = 10000000
  3. --Buffer zone size
  4. local BUFFER_SIZE = 4000000
  5.  
  6. --connect to reactor
  7. local reactor = peripheral.wrap("back")
  8.  
  9. --confirm connection
  10. if(not reactor.getConnected) then
  11.     print("Not connected to Reactor")
  12. end
  13.  
  14. --turn the reactor on
  15. if(not reactor.getActive()) then
  16.     reactor.setActive(true)
  17.     print("Starting Reactor")
  18. end
  19.  
  20. --move control rod to defaul level
  21. reactor.setAllControlRodLevels(0)
  22.  
  23.  
  24. while(true) do
  25.    
  26.     local currentEnergy = reactor.getEnergyStored()
  27.     if (currentEnergy < BUFFER_SIZE) then
  28.         reactor.setActive(true)
  29.     elseif (currentEnergy > (TOTAL_MAX - BUFFER_SIZE) ) then
  30.         reactor.setActive(false)
  31.     end
  32.     sleep(2)
  33.    
  34. end
Add Comment
Please, Sign In to add comment