Advertisement
Guest User

Glass Energy

a guest
Aug 21st, 2014
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. local bridge = peripheral.wrap("left")
  2. local net = peripheral.wrap("back")
  3.  
  4. bridge.clear()
  5.  
  6. local width = 200
  7.  
  8. local storageUnits = {
  9.    {
  10.          ["id"] = "batbox_0",
  11.          ["name"] = "Main Batbox"
  12.    },
  13.    {
  14.          ["id"] = "batbox_1",
  15.          ["name"] = "Another Batbox"
  16.    }
  17. }
  18.  
  19. local offset = 0
  20. for key, storageUnit in pairs(storageUnits) do
  21.   pxOffset = offset * 20
  22.   storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0x000000)
  23.   storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xCC0000, 0.9)
  24.   storageUnit["bar"].setZIndex(2)
  25.   storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5)
  26.   offset = offset + 1
  27. end
  28.  
  29. while true do
  30.   for i=#storageUnits,1,-1 do
  31.         storageUnit = storageUnits[i]
  32.         if net.isPresentRemote(storageUnit["id"]) then
  33.           capacity = net.callRemote(storageUnit["id"], "getCapacity")
  34.           amount = net.callRemote(storageUnit["id"], "getStored")
  35.           storageUnit["bar"].setWidth(width / capacity * amount)
  36.         else
  37.           storageUnit["bar"].delete()
  38.           storageUnit["bg"].delete()
  39.           storageUnit["label"].delete()
  40.           table.remove(storageUnits, i)
  41.         end
  42.   end
  43.   sleep(0.5)
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement