Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MonitorSide = "left"
- Monitor = peripheral.wrap(MonitorSide)
- function ClearMonitor()
- Monitor.setTextColor(colours.black)
- Monitor.setBackgroundColor(colours.black)
- Monitor.clear()
- Monitor.setCursorPos(1,1)
- end
- function DrawText(xPos, yPos, text, textColour, backgroundColour)
- Monitor.setBackgroundColor(backgroundColour)
- Monitor.setTextColor(textColour)
- Monitor.setCursorPos(xPos,yPos)
- Monitor.write(text)
- end
- function DrawLine(x, y, lineLength, colour)
- Monitor.setBackgroundColor(colour)
- Monitor.setTextColor(colour)
- Monitor.setCursorPos(x,y)
- Monitor.write(string.rep(" ", lineLength))
- end
- function ProgressBar(xPos, yPos, barLength, value, maxValue, backgroundColour, progressColour)
- DrawLine(xPos, yPos, barLength, backgroundColour) --backgoround bar
- local barSize = math.floor((value/maxValue) * barLength)
- DrawLine(xPos, yPos, barSize, progressColour) --progress so far
- end
- -- GroupBoxes. these will stretch the entire length of the monitor
- -- they are basically nice visual ways of surrounding data on the screen
- -- Header
- -- rightPadding will take away extra -'s on the right side.
- function GroupBox(xPos, yPos, height, header, textColour, headerBackgroundColour, rightPadding)
- GroupBoxHeader(xPos, yPos, header, textColour, headerBackgroundColour, rightPadding)
- GroupBoxFooter(xPos, yPos + height + 1, textColour, headerBackgroundColour, rightPadding)
- end
- function GroupBoxHeader(xPos, yPos, header, textColour, backgroundColour, rightPadding)
- local repeatChars
- local headerLength = string.len(header)
- local monX, monY = Monitor.getSize()
- repeatChars = monX - 4 - headerLength - rightPadding
- if (repeatChars < 0) then
- repeatChars = 0
- end
- local head = "--- " .. header .. " " .. string.rep("-", repeatChars - rightPadding)
- DrawText(xPos, yPos, head, textColour, backgroundColour)
- end
- function GroupBoxFooter(xPos, yPos, textColour, backgroundColour, rightPadding)
- local repeatChars
- local monX, monY = Monitor.getSize()
- repeatChars = monX - rightPadding
- if (repeatChars < 0) then
- repeatChars = 0
- end
- local head = string.rep("-", repeatChars)
- DrawText(xPos, yPos, head, textColour, backgroundColour)
- end
- function Main()
- while (true) do
- ClearMonitor()
- Monitor.setTextScale(2)
- local monX, monY = Monitor.getSize()
- local heat = math.random(593, 601)
- local cool = math.random(21, 45)
- --GroupBoxHeader(2, 2, "Coolant Temps", colours.orange, colours.black, 1)
- GroupBox(2, 2, 7, "Cooland Temps", colours.orange, colours.black, 1)
- DrawText(2, 4, "INPUT: ", colours.white, colours.black)
- DrawText(9, 4, heat .. " Kelvin", colours.red, colours.black)
- ProgressBar(2, 5, monX - 2, heat, 650, colours.grey, colours.red)
- DrawText(2, 7, "OUTPUT: ", colours.white, colours.black)
- DrawText(10, 7, cool .. " Kelvin", colours.cyan, colours.black)
- ProgressBar(2, 8, monX - 2, cool, 50, colours.grey, colours.cyan)
- --GroupBoxFooter(2, 10, colours.orange, colours.black, 1)
- sleep(1)
- end
- end
- Main()
RAW Paste Data