Advertisement
hypnotizd

Big Reactor Power Management

Mar 3rd, 2015
2,743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. ----------------------------------------------------------
  2. -- Big Reactor Power Management                         --
  3. --                                                      --
  4. -- Minecraft HermitCraft FTB Infinity Episode 15        --
  5. -- https://www.youtube.com/watch?v=Ac-v20Algmg          --
  6. --                                                      --
  7. -- YouTube Channel http://youtube.com/hypnotizd         --
  8. ----------------------------------------------------------
  9.  
  10. local stored = 0
  11. local status = "Discharging"
  12.  
  13. local function setStored()
  14.   stored = peripheral.wrap("right").getEnergyStored("DOWN")
  15. end
  16.  
  17. local function checkPower()
  18.   setStored()
  19.  
  20.   if ((stored / 25000000) >= .85) then
  21.     rs.setOutput("bottom", false)
  22.     status = "Discharging"
  23.   elseif ((stored / 25000000) <= .25) then
  24.     rs.setOutput("bottom", true)
  25.     status = "Charging"
  26.   end
  27. end
  28.  
  29. local function displayStatus()
  30.   local pct = stored/25000000
  31.   term.clear()
  32.   term.setCursorPos(1,1)
  33.  
  34.   print("Current Energy: "..stored.." ("..string.sub(pct,3,4).."."..string.sub(pct,5,6).."%)")
  35.   print("        Status: "..status)
  36. end
  37.  
  38. while true do
  39.   checkPower()
  40.   displayStatus()
  41.   os.sleep(10)
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement