Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bridge = peripheral.wrap("left")
- local net = peripheral.wrap("back")
- bridge.clear()
- local width = 200
- local storageUnits = {
- {
- ["id"] = "batbox_0",
- ["name"] = "Main Batbox"
- },
- {
- ["id"] = "batbox_1",
- ["name"] = "Another Batbox"
- }
- }
- local offset = 0
- for key, storageUnit in pairs(storageUnits) do
- pxOffset = offset * 20
- storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0x000000)
- storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xCC0000, 0.9)
- storageUnit["bar"].setZIndex(2)
- storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5)
- offset = offset + 1
- end
- while true do
- for i=#storageUnits,1,-1 do
- storageUnit = storageUnits[i]
- if net.isPresentRemote(storageUnit["id"]) then
- capacity = net.callRemote(storageUnit["id"], "getCapacity")
- amount = net.callRemote(storageUnit["id"], "getStored")
- storageUnit["bar"].setWidth(width / capacity * amount)
- else
- storageUnit["bar"].delete()
- storageUnit["bg"].delete()
- storageUnit["label"].delete()
- table.remove(storageUnits, i)
- end
- end
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement