Difference between revisions of "Term.getTextColor"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "{{Lowercase}} {{Function |name=term.getTextColor |args= |returns={{type|number}} color code |api=term |addon=ComputerCraft |desc=Gets the current foreground color of the termi...")
 
m
 
Line 6: Line 6:
 
|api=term
 
|api=term
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=Gets the current foreground color of the terminal. Returns the same decimal color codes as seen in [[Colors_(API)#Colors|this page]]. Also available as '''term.getTextColour''' for British spelling.
+
|desc=Gets the current text color of the terminal. Returns the same decimal color codes as seen in [[Colors_(API)#Colors|this page]]. Also available as '''term.getTextColour''' for British spelling.
 
<br>
 
<br>
 
See also: [[term.setTextColor]]()
 
See also: [[term.setTextColor]]()

Latest revision as of 12:08, 28 June 2015


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 )