Advertisement
Guest User

test

a guest
Oct 19th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. local sides = { "left", "right", "top",
  2.   "bottom", "front", "back" }
  3. local mon = peripheral.wrap("back")
  4.  
  5. os.loadAPI("ProgressBar")
  6. ProgressBar.SetPeripheral("back")
  7.  
  8. function checkIsSide(str)
  9.   for i=1, #sides do
  10.     if str == sides[i] then return true end
  11.   end
  12.   return false
  13. end
  14.  
  15.  
  16. local num = 1
  17. local maxNum = 1
  18. mon.setTextScale(3)
  19. mon.setCursorPos(1,1)
  20. mon.write("Tank Monitoring")
  21. mon.setTextScale(2)
  22. while true do
  23.   peripherals = peripheral.getNames()
  24.   num = 1
  25.   for i=1, #peripherals do
  26.     local name = peripherals[i]
  27.     local displayName = peripherals[i]
  28.     if checkIsSide(name) == false then
  29.           num = num + 1
  30.                  
  31.       if string.find(name, "tank") then
  32.         tank = peripheral.wrap(name)
  33.         info = tank.getTankInfo("unknown")
  34.                 local max = 0
  35.                 local current = 0
  36.         for u, v in pairs(info) do
  37.           for column,data in pairs(v) do            
  38.             print(column..
  39.               ": "..data)
  40.             if column == "capacity" then
  41.               max = data
  42.             elseif column == "amount" then
  43.               current = data
  44.             elseif column == "rawName" then
  45.               mod = data.."                             "
  46.               displayName = mod
  47.             end
  48.           end
  49.         end
  50.         mon.setCursorPos(1, num)
  51.         mon.write(displayName)
  52.         ProgressBar.SetTable(name, max, current, 15, 25, num)
  53.         ProgressBar.DrawToPeripheral()
  54.       else
  55.         mon.setCursorPos(1, num)
  56.         mon.write("                                                        ")
  57.       ProgressBar.ClearSingle(name)
  58.    ProgressBar.DrawToPeripheral()
  59.   end
  60.     end
  61.   end  
  62.   if num > maxNum then maxNum = num end
  63.   sleep(5)
  64. --  break
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement