kriNon

Untitled

Dec 29th, 2015
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. local function padLeft(str, w)
  2. return string.rep(" ", w - #str) .. str
  3. end
  4.  
  5. --[[
  6. * Locate the nearest
  7. ]]
  8. local function findPeripheral(_type)
  9. for _,name in pairs(peripheral.getNames()) do
  10. if peripheral.getType(name) == _type then
  11. return peripheral.wrap(name)
  12. end
  13. end
  14. end
  15.  
  16.  
  17. local totalCap = 0
  18. local totalStore = 0
  19. local percent = 0
  20. local mfsu
  21.  
  22. os.startTimer(1)
  23.  
  24. while true do
  25. totalCap = peripheral.call("back", getEUCapacity())
  26. totalStore = peripheral.call("back", getEUStored())
  27.  
  28. -- Calculate a percentage
  29. percent = math.ceil(totalStore / totalCap) * 100
  30.  
  31. -- Analogue redstone output
  32. redstone.setAnalogOutput("right", (math.ceil(totalStore / totalCap) * 15))
  33.  
  34. os.pullEvent("timer")
  35. os.startTimer(1)
  36. end
Add Comment
Please, Sign In to add comment