Advertisement
Dizzybabe99

Cam

Oct 20th, 2014
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.27 KB | None | 0 0
  1. local bridge = peripheral.wrap("right")
  2. local net = peripheral.wrap("bottom")
  3. local restart = 0
  4.  
  5. bridge.clear()
  6.  
  7. local width = 200
  8.  
  9. local storageUnits = {
  10.    {
  11.          ["id"] = "cofh_thermalexpansion_energycell_1",
  12.          ["name"] = "Main Energycell",
  13.                  ["type"] = "te"
  14.    },
  15.    {
  16.          ["id"] = "cofh_thermalexpansion_energycell_2",
  17.          ["name"] = "LogisticPipes Extra Power",
  18.                  ["type"] = "te"
  19.    },
  20.    {
  21.          ["id"] = "cofh_thermalexpansion_energycell_4",
  22.          ["name"] = "Laser Power",
  23.                  ["type"] = "te"
  24.    },
  25.    {
  26.          ["id"] = "cofh_thermalexpansion_energycell_3",
  27.          ["name"] = "Swap Cell",
  28.                  ["type"] = "te"
  29.    },
  30. {
  31.          ["id"] = "ender_tank_0",
  32.          ["name"] = "Lava",
  33.                  ["nameC"] = "Lava",
  34.                  ["type"] = "Liquid"
  35.    }
  36. }
  37.  
  38. local offset = 1
  39. for key, storageUnit in pairs(storageUnits) do
  40.   pxOffset = offset * 20
  41.   storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0x6b6b6b)
  42.   storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xCC0000, 0.9)
  43. --  storageUnit["bar"].setZIndex(2)
  44.   storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5)
  45.   offset = offset + 1
  46. print(offset)
  47. end
  48. storageUnit = storageUnits[4]
  49. print(storageUnit["type"])
  50. while true do
  51.   for i=#storageUnits,1,-1 do
  52.         storageUnit = storageUnits[i]
  53.         if net.isPresentRemote(storageUnit["id"]) then
  54.                         if storageUnit["type"] == "ic" then
  55.                           capacity = net.callRemote(storageUnit["id"], "getEUCapacity")
  56.                           amount = net.callRemote(storageUnit["id"], "getEUStored")
  57.                           storageUnit["bar"].setWidth(width / capacity * amount)
  58.                         elseif storageUnit["type"] == "te" then
  59.                           capacity = net.callRemote(storageUnit["id"], "getMaxEnergyStored", "unknown")
  60.                           amount = net.callRemote(storageUnit["id"], "getEnergyStored", "unknown")
  61.                           storageUnit["bar"].setWidth(width / capacity * amount)
  62.                           storageUnit["bar"].setColor(0x009c00)
  63.                         elseif storageUnit["type"] == "Liquid" then
  64.                           m = peripheral.wrap(storageUnit["id"])
  65.                           tanksTable = m.getTankInfo("unknown")
  66.                           maintank = tanksTable[1]
  67.                           if maintank.amount == nil then maintank.amount = 0 end
  68.                           capacity = maintank.capacity
  69.                           amount = maintank.amount
  70.                           storageUnit["bar"].setWidth(width / capacity * amount)
  71.                           storageUnit["bar"].setColor(0xdc0000)
  72.                           storageUnit["name"] = storageUnits[i]["nameC"].." ("..maintank.amount.."/"..maintank.capacity..")"
  73.                           --print(storageUnit["name"])
  74.                           storageUnit["label"].setText(storageUnit["name"])
  75.                         end
  76.         else
  77.           storageUnit["bar"].setWidth(0)
  78.         end
  79.   end
  80.           if restart > 500 then
  81.           --shell.run("reboot")
  82.           end
  83.   restart = restart+1
  84.   print(restart)
  85.   sleep(0.01)
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement