Advertisement
Guest User

test

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