KapitanWalnut

EssenceManager

May 13th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. local essenceTank = peripheral.wrap("top")
  2. local tankInfo = essenceTank.getTankInfo("unknown")[1]
  3. local capacity = tankInfo.capacity or 0
  4. local amount = tankInfo.amount or 0
  5. local percentage = 0
  6.  
  7. local threshold = 90
  8. local lagbuster = 10
  9.  
  10. local rs_side = "left"
  11. local rs_color = colors.lightBlue
  12.  
  13.  
  14. local function getAmount()
  15.   tankInfo = essenceTank.getTankInfo("unknown")[1]
  16.   amount = tankInfo.amount or 0
  17. end
  18.  
  19. local function getPercent()
  20.   getAmount()
  21.   percentage = math.floor(amount/capacity*100)
  22.   print("Percent filled: ", tostring(percentage),"%")
  23. end
  24.  
  25. local function setRedstone()
  26.   getPercent()
  27.   if percentage > threshold then
  28.     rs.setBundledOutput(rs_side, rs_color)
  29.     print("Above")
  30.   else
  31.     rs.setBundledOutput(rs_side, 0)
  32.     print("Below")
  33.   end
  34. end
  35.  
  36. local function main()
  37.   while true do
  38.     setRedstone()
  39.     sleep(lagbuster)
  40.   end
  41. end
  42. main()
Advertisement
Add Comment
Please, Sign In to add comment