kriNon

Untitled

Dec 29th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 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. -- Start getting numbers
  26. totalCap = 0
  27. totalStore = 0
  28. percent = 0
  29.  
  30. for v in (peripheral.getNames()) do
  31. if peripheral.getType(v) == "mfsu" then
  32. mfsu = peripheral.wrap(v)
  33. totalCap = mfsu.getEUCapacity()
  34. totalStore = mfsu.getEUStored()
  35. end
  36. end
  37.  
  38. -- Calculate a percentage
  39. percent = math.ceil(totalStore / totalCap) * 100
  40.  
  41. -- Analogue redstone output
  42. redstone.setAnalogOutput("right", (math.ceil(totalStore / totalCap) * 15))
  43.  
  44. os.pullEvent("timer")
  45. os.startTimer(1)
  46. end
Advertisement
Add Comment
Please, Sign In to add comment