term.getTextColor

From ComputerCraft Wiki
Revision as of 12:08, 28 June 2015 by MKlegoman357 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Grid Redstone.png  Function term.getTextColor
Gets the current text color of the terminal. Returns the same decimal color codes as seen in this page. Also available as term.getTextColour for British spelling.


See also: term.setTextColor()
Syntax term.getTextColor()
Returns number color code
Part of ComputerCraft
API term

Examples

Grid paper.png  Example
Prints the current text color of the terminal.
Code
local currentTextColor = term.getTextColor()

print( "The current text color is: ", currentTextColor )



Grid paper.png  Example
Prints the current text color name (rather than the number) of the terminal.
Code
local currentTextColor = term.getTextColor()
local colorName = "Unknown"

for key, value in pairs( colors ) do -- find the name of the color
  if value == currentTextColor then
    colorName = key
    break
  end
end

print( "The current text color is: ", colorName )