Advertisement
Guest User

test

a guest
Oct 19th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 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. while true do
  16.   peripherals = peripheral.getNames()
  17.   for i=1, #peripherals do
  18.     if checkIsSide(peripherals[i]) == false then
  19.       local name = peripherals[i]
  20.       if ProgressBar[peripherals[i]] == nil then
  21.         ProgressBar[peripherals[i]] = {}
  22.         ProgressBar[peripherals[i]]["XMin"] = 27
  23.         ProgressBar[peripherals[i]]["XMax"] = 47
  24.         ProgressBar[peripherals[i]]["YVal"] = i
  25.       end
  26.       if string.find(peripherals[i], "tank") then
  27.         tank = peripheral.wrap(peripherals[i])
  28.         info = tank.getTankInfo("unknown")
  29.         for u, v in pairs(info) do
  30.           for column,data in pairs(v) do            
  31.             print(column..
  32.               ": "..data)
  33.             if column == "capacity" then
  34.               ProgressBar[peripherals[i]]["Max"] = data
  35.             elseif column == "amount" then
  36.               ProgressBar[peripherals[i]["Current"] = data
  37.             end
  38.           end
  39.         end
  40.       end
  41.       mon.setCursorPos(1, i)
  42.       mon.write(name)
  43.       ProgressBar.DrawToPeripheral()
  44.     end
  45.   end  
  46.   break
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement