EphemeralKap

Untitled

Dec 27th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 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"
  12. }
  13. }
  14.  
  15. local offset = 0
  16. for key, storageUnit in pairs(storageUnits) do
  17. pxOffset = offset * 20
  18. storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0x000000)
  19. storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xCC0000, 0.9)
  20. storageUnit["bar"].setZIndex(2)
  21. storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5)
  22. offset = offset + 1
  23. end
  24.  
  25. while true do
  26. for i=#storageUnits,1,-1 do
  27. storageUnit = storageUnits[i]
  28. if net.isPresentRemote(storageUnit["id"]) then
  29. if net.getTypeRemote(storageUnit["id"]) == "batbox" then
  30. capacity = net.callRemote(storageUnit["id"], "getCapacity")
  31. amount = net.callRemote(storageUnit["id"], "getStored")
  32. storageUnit["bar"].setWidth(width / capacity * amount)
  33. end
  34. else
  35. storageUnit["bar"].delete()
  36. storageUnit["bg"].delete()
  37. storageUnit["label"].delete()
  38. table.remove(storageUnits, i)
  39. end
  40. end
  41. sleep(0.5)
  42. end
Advertisement
Add Comment
Please, Sign In to add comment