Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- by ther/carrot xd
- -- Monitor is required, but you could set it to term
- -- if you want it to draw stuff to the terminal screen
- -- so... Monitor = term
- 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 DrawCenteredHorizontal(xPos, yPos, width, text, textColour, backgroundColour)
- -- width could be the size of your monitor, or anything else. this means it
- -- doesn't have to stretch your entire monitor's if you want. imagine
- -- it as a rectangle and the text is in the center.
- local textLength = string.len(text)
- local centerX = (width / 2) - (textLength / 2)
- DrawText(xPos + centerX, yPos, text, textColour, backgroundColour)
- end
- function DrawLineH(xPos, yPos, lineLength, colour)
- Monitor.setBackgroundColor(colour)
- Monitor.setTextColor(colour)
- Monitor.setCursorPos(xPos,yPos)
- Monitor.write(string.rep(" ", lineLength))
- end
- function DrawLineV(xPos, yPos, width, lineHeight, colour)
- Monitor.setBackgroundColor(colour)
- for i = 1, lineHeight, 1 do
- Monitor.setCursorPos(xPos, yPos + (i - 1))
- Monitor.write(string.rep(" ", width))
- end
- end
- function DrawSquare(xPos, yPos, nWidth, nHeight, backgroundColour)
- Monitor.setBackgroundColor(backgroundColour)
- for i = 1, math.ceil(nHeight), 1 do
- Monitor.setCursorPos(xPos, yPos + (i - 1))
- Monitor.write(string.rep(" ", nWidth))
- end
- end
- function ProgressBar(xPos, yPos, width, value, maxValue, backgroundColour, progressColour)
- DrawLineH(xPos, yPos, width, backgroundColour) --backgoround bar
- local barSize = math.floor((value/maxValue) * width)
- DrawLineH(xPos, yPos, barSize, progressColour) --progress so far
- end
- function GroupBoxHeader(xPos, yPos, width, header, textColour, backgroundColour)
- local headerLength = string.len(header)
- local repeatChars = width - 4 - headerLength
- if (repeatChars < 0) then
- repeatChars = 0
- end
- local head = "--- " .. header .. " " .. string.rep("-", repeatChars)
- DrawText(xPos, yPos, head, textColour, backgroundColour)
- end
- function GroupBoxFooter(xPos, yPos, width, textColour, backgroundColour)
- if (width < 0) then
- width = 0
- end
- local head = string.rep("-", width)
- DrawText(xPos, yPos, head, textColour, backgroundColour)
- end
- function GroupBox(xPos, yPos, width, height, header, textColour, headerBackgroundColour)
- GroupBoxHeader(xPos, yPos, width, header, textColour, headerBackgroundColour)
- GroupBoxFooter(xPos, yPos + height + 1, width, textColour, headerBackgroundColour)
- end
RAW Paste Data