Advertisement
CrowbarSr

Terminal Glasses HUD

Aug 9th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1. --Place the Terminal Glasses Bridge to the RIGHT of the Advanced Computer
  2. --Place a Wired Modem to the back of the Advanced Computer and on one of the sides of your energy device
  3. --Connect the 2 Wired Modems with Networking Cables
  4. --Activate the Wired Modems by right clicking on them
  5. --You'll be given an ID when activating the modem. Replace 'idsu_0' with that ID.
  6.  
  7. local msg
  8. local command
  9.  
  10. local bridge = peripheral.wrap("right")
  11. local net = peripheral.wrap("back")
  12.  
  13. local function idsu()
  14.         bridge.clear()
  15.         local width = 100
  16.         local storageUnits = {
  17.            {
  18.                  ["id"] = "idsu_2",
  19.                  ["name"] = "IDSU"
  20.            }
  21.          
  22.         }
  23.  
  24.         local offset = 0
  25.         for key, storageUnit in pairs(storageUnits) do
  26.           pxOffset = offset * 20
  27.           storageUnit["label"] = bridge.addText(4, 34 + pxOffset, storageUnit["name"], 0xFFFFFF)
  28.           storageUnit["bar"] = bridge.addBox(4, 44 + pxOffset, 0, 5, 0xCC0000, 0.9)
  29.           storageUnit["bar"].setZIndex(2)
  30.           storageUnit["bg"] = bridge.addBox(4, 44 + pxOffset, width, 5, 0x000000, 0.5)
  31.           offset = offset + 1
  32.         end
  33.          
  34.         while true do
  35.           for i=#storageUnits,1,-1 do
  36.                 storageUnit = storageUnits[i]
  37.                 if net.isPresentRemote(storageUnit["id"]) then
  38.                   capacity = net.callRemote(storageUnit["id"], "getCapacity")
  39.                   amount = net.callRemote(storageUnit["id"], "getStored")
  40.                   storageUnit["bar"].setWidth(width / capacity * amount)
  41.                 else
  42.                   storageUnit["bar"].delete()
  43.                   storageUnit["bg"].delete()
  44.                   storageUnit["label"].delete()
  45.                   table.remove(storageUnits, i)
  46.                 end
  47.           end
  48.           sleep(0.5)
  49. end
  50. end
  51. local function pullChat()
  52.   local e
  53.   e, msg = os.pullEvent("chat_command")
  54. end
  55.  
  56.  
  57. while true do
  58.   if command == "idsu" then
  59.     parallel.waitForAny(pullChat,idsu)
  60.   else
  61.     pullChat()
  62.   end
  63.   if msg == "idsu" then
  64.     command = "idsu"
  65.   elseif msg == "clear" then
  66.     command = bridge.clear()
  67.   end
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement