Advertisement
BookerTheGeek

BigReactor passive cooled fuel rod controller

Nov 5th, 2020 (edited)
2,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | Gaming | 0 0
  1. -- BigReactor passive cooled fuel rod controller
  2. -- By BookerTheGeek
  3.  
  4. -- Variables
  5. local reactor = peripheral.wrap("back")
  6. local maxEnergy = reactor.getEnergyCapacity()
  7. local run = true
  8.  
  9.  
  10. -- The Goods
  11. while run == true do
  12.  
  13. -- Check if Reactor is Formed
  14.  if reactor.mbIsAssembled() == false then
  15.   term.clear()
  16.   term.setCursorPos(1,1)
  17.   print("Reactor not formed")
  18.   sleep(1)
  19.  else
  20.  
  21. -- Turn Reactor On if Off
  22.  if reactor.getActive() ~= "true" then
  23.   reactor.setActive(true)
  24.  end
  25.  
  26. -- Figure out Energy stored as a %
  27.  storedEnergy = reactor.getEnergyStored()
  28.  percentFull = math.floor(storedEnergy / maxEnergy * 100)
  29.  
  30. -- Make sure we are not going over 100 or under 0
  31.  if percentFull >= 100 then percentFull = 100 end
  32.  if percentFull <= 0   then percentFull = 0   end
  33.  
  34. -- Control the Control Rods
  35.  reactor.setAllControlRodLevels(percentFull)
  36.  
  37. -- Output Information
  38.  term.clear()
  39.  term.setCursorPos(1,1)
  40.  print("RF:", storedEnergy )
  41.  print("Rod % ", percentFull)
  42.  
  43. -- Wait to run again
  44.  sleep(1)
  45.  
  46. -- End the Loop
  47.  end
  48. end
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement