Advertisement
bobmarley12345

ccNasaFacilityPowerPC

Oct 7th, 2020 (edited)
1,988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. Monitor = peripheral.wrap(MonitorSide)
  2.  
  3. function ClearMonitor()
  4.     Monitor.setTextColor(colours.black)
  5.     Monitor.setBackgroundColor(colours.black)
  6.     Monitor.clear()
  7.     Monitor.setCursorPos(1,1)
  8. end
  9.  
  10. function DrawText(xPos, yPos, text, textColour, backgroundColour)
  11.     Monitor.setBackgroundColor(backgroundColour)
  12.     Monitor.setTextColor(textColour)
  13.     Monitor.setCursorPos(xPos,yPos)
  14.     Monitor.write(text)
  15. end
  16.  
  17. function DrawLine(x, y, lineLength, colour)
  18.     Monitor.setBackgroundColor(colour)
  19.     Monitor.setTextColor(colour)
  20.     Monitor.setCursorPos(x,y)
  21.     Monitor.write(string.rep(" ", lineLength))
  22. end
  23.  
  24. function ProgressBar(xPos, yPos, barLength, value, maxValue, backgroundColour, progressColour)
  25.     DrawLine(xPos, yPos, barLength, backgroundColour) --backgoround bar
  26.     local barSize = math.floor((value/maxValue) * barLength)
  27.     DrawLine(xPos, yPos, barSize, progressColour) --progress so far
  28. end
  29.  
  30. function Main()
  31.     while true do
  32.         ClearMonitor()
  33.  
  34.         Monitor.setTextScale(2)
  35.  
  36.         local monX, monY = Monitor.getSize()
  37.    
  38.         DrawText(2, 2, "Facility Power: ", colours.white, colours.black)
  39.         DrawText(19, 2, "ONLINE", colours.green, colours.black)
  40.    
  41.         DrawText(2, 4, "Backup Power Buffer", colours.white, colours.black)
  42.         ProgressBar(2, 5, monX - 2, math.random(88, 99), 100, colours.grey, colours.green)
  43.    
  44.         DrawText(2, 7, string.rep("-", monX - 2), colours.grey, colours.black)
  45.    
  46.         DrawText(2, 9, "Facility Voltage: ", colours.white, colours.black)
  47.         DrawText(20, 9, (math.random(49, 50) .. " kV"), colours.orange, colours.black)
  48.  
  49.         DrawText(2, 11, "Current Draw: ", colours.white, colours.black)
  50.         DrawText(16, 11, (math.random(378, 412) .. " amps"), colours.red, colours.black)
  51.  
  52.         sleep(0.5)
  53.     end
  54. end
  55.  
  56. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement