Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local textColorBuffer = colors.white -- The color that is currently being used for the default text color.
- local backgroundColorBuffer = colors.black -- The color that is currently being used for the default background color.
- -- Set the text and background colors to their defaults.
- term.setTextColor(textColorBuffer)
- term.setBackgroundColor(backgroundColorBuffer)
- -- Sets the cursor to the given position and the text and background colors if provided, then
- -- writes the text to the screen.
- function positionAndWrite(xPos, yPos, text, textColor, backgroundColor)
- term.setCursorPos(xPos, yPos)
- term.setTextColor(isColorValid(textColor) or textColorBuffer)
- term.setBackgroundColor(isColorValid(backgroundColor) or backgroundColorBuffer)
- term.write(text)
- end
- -- Writes the given text to the screen with the given text and background colors.
- function writeWithColor(text, textColor, backgroundColor)
- term.setTextColor(isColorValid(textColor) or textColorBuffer)
- term.setBackgroundColor(isColorValid(backgroundColor) or backgroundColorBuffer)
- term.write(text)
- end
- -- Returns the color given if it is valid, and nil if it was false.
- function isColorValid(color)
- for index, colorVal in pairs(colors) do
- if colorVal == color then
- return color
- end
- end
- return nil
- end
- -- Returns the current text and background colors in the buffer.
- function getBufferColors()
- return textColorBuffer, backgroundColorBuffer
- end
Advertisement
Add Comment
Please, Sign In to add comment