Advertisement
Dojnaz

CC DojnazGlass

Nov 20th, 2020 (edited)
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local mon = peripheral.wrap("left")
  2. local glass = peripheral.wrap("right")
  3. local me = peripheral.wrap("appeng_me_tilecraftingterminal_2")
  4. local colorRange = {0x04ff00, 0x6fff00, 0x91ff00, 0xbfff00, 0xfbff00, 0xffdd00, 0xffb700, 0xff7b00, 0xff5500, 0xff0000}
  5. me.getUsedBytes = me.getUnusedBytes
  6.  
  7. function glassUpdate()
  8.     while (true) do
  9.     glass.clear()
  10.     glass.addBox(0,0,52,18,colorRange[math.floor((me.getUsedBytes() / me.getTotalBytes()) * 10)],1)
  11.       glass.addText(5, 5, "ME: " .. math.floor((me.getUsedBytes() / me.getTotalBytes()) * 100) .. "%", 0xffffff)
  12.     sleep(5)
  13.     end
  14. end
  15.  
  16. function monitorUpdate()
  17.   while (true) do
  18.     mon.clear()
  19.     mon.setCursorPos(1,1)
  20.     if (#glass.getUsers() == 0) then
  21.       mon.write("No active users :(")
  22.     else
  23.       mon.write("Active Users")
  24.             users = glass.getUsers()
  25.             i = 1
  26.             for key, value in pairs(users) do
  27.                 i = i + 1
  28.                 mon.setCursorPos(1,i)
  29.                 mon.write(key .. " " .. tostring(value))
  30.             end
  31.         end
  32.     sleep(1)
  33.   end
  34. end
  35.  
  36. parallel.waitForAll(glassUpdate, monitorUpdate)
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement