Advertisement
bobmarley12345

ccNasaFacilityInternetPC

Oct 7th, 2020 (edited)
2,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.16 KB | None | 0 0
  1. MonitorSide = "left"
  2. Monitor = peripheral.wrap(MonitorSide)
  3.  
  4. function ClearMonitor()
  5.     Monitor.setTextColor(colours.black)
  6.     Monitor.setBackgroundColor(colours.black)
  7.     Monitor.clear()
  8.     Monitor.setCursorPos(1,1)
  9. end
  10.  
  11. function DrawText(xPos, yPos, text, textColour, backgroundColour)
  12.     Monitor.setBackgroundColor(backgroundColour)
  13.     Monitor.setTextColor(textColour)
  14.     Monitor.setCursorPos(xPos,yPos)
  15.     Monitor.write(text)
  16. end
  17.  
  18. function DrawLine(x, y, lineLength, colour)
  19.     Monitor.setBackgroundColor(colour)
  20.     Monitor.setTextColor(colour)
  21.     Monitor.setCursorPos(x,y)
  22.     Monitor.write(string.rep(" ", lineLength))
  23. end
  24.  
  25. function ProgressBar(xPos, yPos, barLength, value, maxValue, backgroundColour, progressColour)
  26.     DrawLine(xPos, yPos, barLength, backgroundColour) --backgoround bar
  27.     local barSize = math.floor((value/maxValue) * barLength)
  28.     DrawLine(xPos, yPos, barSize, progressColour) --progress so far
  29. end
  30.  
  31. function Main()
  32.     while true do
  33.         ClearMonitor()
  34.  
  35.         Monitor.setTextScale(2)
  36.  
  37.         local monX, monY = Monitor.getSize()
  38.    
  39.         DrawText(2, 2, "Facility Bandwidth: ", colours.white, colours.black)
  40.         DrawText(22, 2, (math.random(89, 93) .. " GBit"), colours.lightBlue, colours.black)
  41.  
  42.         DrawText(2, 4, "Downloaded previous second: ", colours.white, colours.black)
  43.         DrawText(2, 5, (math.random(68, 144) .. " Megabits"), colours.green, colours.black)
  44.  
  45.         DrawText(2, 7, ("--- Packets " .. string.rep("-", monX - 14)), colours.lightBlue, colours.black)
  46.  
  47.         DrawText(2, 9, "Packet Buffer Health", colours.white, colours.black)
  48.         ProgressBar(2, 10, monX - 2, math.random(97, 100), 100, colours.grey, colours.cyan)
  49.    
  50.         DrawText(2, 12, "Packets Lost last second", colours.white, colours.black)
  51.         DrawText(2, 13, (math.random(0, 3) .. " packets"), colours.red, colours.black)
  52.  
  53.         DrawText(2, 15, string.rep("-", monX - 2), colours.lightBlue, colours.black)
  54.  
  55.         DrawText(2, 17, "Intrusions Detected: ", colours.white, colours.black)
  56.         DrawText(23, 17, "0", colours.red, colours.black)
  57.        
  58.         sleep(0.5)
  59.     end
  60. end
  61.  
  62. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement