Advertisement
hypnotizd

FTB Infinity Evolved Big Reactor Basic Power Management

Feb 6th, 2016
5,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1. ----------------------------------------------------------
  2. -- Big Reactor Power Management                         --
  3. --                                                      --
  4. -- Minecraft FTB Infinity Evolved Episode 50            --
  5. -- https://www.youtube.com/watch?v=BT5e9N3vHVU          --
  6. --                                                      --
  7. -- YouTube Channel http://youtube.com/hypnotizd         --
  8. ----------------------------------------------------------
  9.  
  10. local reactor = peripheral.wrap("back")
  11. local stored = 0
  12. local prevStored = 0
  13. local lastTick = 0
  14. local status = "Discharging"
  15.  
  16. local function setLastTick()
  17.   lastTick = reactor.getEnergyProducedLastTick()
  18. end
  19.  
  20. local function setStored()
  21.   stored = reactor.getEnergyStored()
  22. end
  23.  
  24. local function checkPower()
  25.   setStored()
  26.   setLastTick()
  27.  
  28.   if (stored > 8000000) then
  29.     reactor.setAllControlRodLevels(100)
  30.     status = "Discharging"
  31.   elseif (stored <= 2000000) then
  32.     reactor.setAllControlRodLevels(0)
  33.     status = "Charging"
  34.   end
  35. end
  36.  
  37. local function displayStatus()
  38.   local pct = stored/10000000
  39.   term.clear()
  40.   term.setCursorPos(1,1)
  41.   local usage = (stored - prevStored)/20
  42.  
  43.   print(" Current Energy: "..math.floor(stored))
  44.   print("Energy Produced: "..math.floor(lastTick).." RF/t")
  45.   print("          Usage: "..math.floor(usage).." RF/t")
  46.   print("         Status: "..status)
  47. end
  48.  
  49. while true do
  50.   checkPower()
  51.   displayStatus()
  52.   prevStored = stored
  53.   os.sleep(1)
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement