Advertisement
bobmarley12345

CCNasaRocketInfoPC

Oct 7th, 2020 (edited)
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.85 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(xPos, yPos, lineLength, colour)
  19.     Monitor.setBackgroundColor(colour)
  20.     Monitor.setTextColor(colour)
  21.     Monitor.setCursorPos(xPos,yPos)
  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 GroupBox(xPos, yPos, height, header, textColour, headerBackgroundColour, rightPadding)
  32.     GroupBoxHeader(xPos, yPos, header, textColour, headerBackgroundColour, rightPadding)
  33.     GroupBoxFooter(xPos, yPos + height + 1, textColour, headerBackgroundColour, rightPadding)
  34. end
  35.  
  36. function GroupBoxHeader(xPos, yPos, header, textColour, backgroundColour, rightPadding)
  37.     local repeatChars
  38.     local headerLength = string.len(header)
  39.    
  40.     local monX, monY = Monitor.getSize()
  41.     repeatChars = monX - 4 - headerLength - rightPadding
  42.  
  43.     if (repeatChars < 0) then
  44.         repeatChars = 0
  45.     end
  46.  
  47.     local head = "--- " .. header .. " " .. string.rep("-", repeatChars - rightPadding)
  48.     DrawText(xPos, yPos, head, textColour, backgroundColour)
  49. end
  50.  
  51. function GroupBoxFooter(xPos, yPos, textColour, backgroundColour, rightPadding)
  52.     local repeatChars
  53.    
  54.     local monX, monY = Monitor.getSize()
  55.     repeatChars = monX - rightPadding
  56.  
  57.     if (repeatChars < 0) then
  58.         repeatChars = 0
  59.     end
  60.  
  61.     local head = string.rep("-", repeatChars)
  62.     DrawText(xPos, yPos, head, textColour, backgroundColour)
  63. end
  64.  
  65. function Main()
  66.     while (true) do
  67.         ClearMonitor()
  68.         Monitor.setTextScale(2)
  69.         local monX, monY = Monitor.getSize()
  70.  
  71.         DrawText(2, 2, "Rocket Engines: ", colours.white, colours.black)
  72.         DrawText(18, 2, "ACTIVE", colours.green, colours.black)
  73.  
  74.         local thrust = math.random(95, 100)
  75.         local thrustKG = thrust * 1800
  76.         DrawText(2, 4, "Rocket Thrust: ", colours.white, colours.black)
  77.         DrawText(17, 4, thrust .. "%", colours.green, colours.black)
  78.         DrawText(2, 5, "Rocket Force", colours.white, colours.black)
  79.         DrawText(17, 5, thrustKG .. " KG", colours.orange, colours.black)
  80.  
  81.         ProgressBar(2, 6, monX - 2, thrust, 100, colours.grey, colours.green)
  82.  
  83.         sleep(1)
  84.     end
  85. end
  86.  
  87. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement