Advertisement
Guest User

startup

a guest
Mar 1st, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. --b = peripheral.wrap("top")
  2. term.clear()
  3. limit = 20
  4.  
  5. local function getPercentStored()
  6.   b = peripheral.wrap("back")
  7.   max = b.getMaxEnergyStored()
  8.   stored = b.getEnergyStored()
  9.  
  10.   a = max / 100
  11.   b = stored / a
  12.   return math.ceil(b)
  13. end
  14.  
  15. recharge = "off"
  16. local function runCheck()
  17.   --term.clear()
  18.   term.setCursorPos(1,1)
  19.   print(textutils.formatTime(os.time(), false))
  20.   print("Stored: "..getPercentStored().."% ")
  21.   print(" ")
  22.   print("Charge when below "..limit.."% ")
  23.   print("Reactor: "..recharge.."  ")
  24.  
  25.   if recharge == "on" then
  26.     --turn redstone signal on!
  27.     redstone.setOutput("left",true)
  28.   else
  29.     --turn redstone signal off!
  30.     redstone.setOutput("left",false)
  31.   end
  32.  
  33.   if getPercentStored() < limit then
  34.     recharge = "on"
  35.   elseif (getPercentStored() > 95)
  36.   and (recharge == "on") then
  37.     recharge = "off"
  38.   end
  39.  
  40.  
  41. end
  42.  
  43. while true do
  44.   --sleep(1)
  45.   runCheck()
  46.   sleep(1)
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement