bobmarley12345

NasaCoolandPC

Oct 7th, 2020 (edited)
903
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. -- GroupBoxes. these will stretch the entire length of the monitor
  32. -- they are basically nice visual ways of surrounding data on the screen
  33. -- Header
  34. -- rightPadding will take away extra -'s on the right side.
  35.  
  36. function GroupBox(xPos, yPos, height, header, textColour, headerBackgroundColour, rightPadding)
  37.     GroupBoxHeader(xPos, yPos, header, textColour, headerBackgroundColour, rightPadding)
  38.     GroupBoxFooter(xPos, yPos + height + 1, textColour, headerBackgroundColour, rightPadding)
  39. end
  40.  
  41. function GroupBoxHeader(xPos, yPos, header, textColour, backgroundColour, rightPadding)
  42.     local repeatChars
  43.     local headerLength = string.len(header)
  44.    
  45.     local monX, monY = Monitor.getSize()
  46.     repeatChars = monX - 4 - headerLength - rightPadding
  47.  
  48.     if (repeatChars < 0) then
  49.         repeatChars = 0
  50.     end
  51.  
  52.     local head = "--- " .. header .. " " .. string.rep("-", repeatChars - rightPadding)
  53.     DrawText(xPos, yPos, head, textColour, backgroundColour)
  54. end
  55.  
  56. function GroupBoxFooter(xPos, yPos, textColour, backgroundColour, rightPadding)
  57.     local repeatChars
  58.    
  59.     local monX, monY = Monitor.getSize()
  60.     repeatChars = monX - rightPadding
  61.  
  62.     if (repeatChars < 0) then
  63.         repeatChars = 0
  64.     end
  65.  
  66.     local head = string.rep("-", repeatChars)
  67.     DrawText(xPos, yPos, head, textColour, backgroundColour)
  68. end
  69.  
  70. function Main()
  71.     while (true) do
  72.         ClearMonitor()
  73.         Monitor.setTextScale(2)
  74.         local monX, monY = Monitor.getSize()
  75.  
  76.         local heat = math.random(593, 601)
  77.         local cool = math.random(21, 45)
  78.  
  79.         --GroupBoxHeader(2, 2, "Coolant Temps", colours.orange, colours.black, 1)
  80.  
  81.         GroupBox(2, 2, 7, "Cooland Temps", colours.orange, colours.black, 1)
  82.  
  83.         DrawText(2, 4, "INPUT: ", colours.white, colours.black)
  84.         DrawText(9, 4, heat .. " Kelvin", colours.red, colours.black)
  85.         ProgressBar(2, 5, monX - 2, heat, 650, colours.grey, colours.red)
  86.  
  87.         DrawText(2, 7, "OUTPUT: ", colours.white, colours.black)
  88.         DrawText(10, 7, cool .. " Kelvin", colours.cyan, colours.black)
  89.         ProgressBar(2, 8, monX - 2, cool, 50, colours.grey, colours.cyan)
  90.  
  91.         --GroupBoxFooter(2, 10, colours.orange, colours.black, 1)
  92.  
  93.         sleep(1)
  94.     end
  95. end
  96.  
  97. Main()
RAW Paste Data