term.getTextColour

From ComputerCraft
(Redirected from Term.getTextColor)
Jump to: navigation, search

term.getTextColour
Function
Syntax
term.getTextColour()
Returns number colour
API term
Source CC:Tweaked (source)

Returns the numerical value of the current text colour of the terminal object.

ExampleExampleGet text colour
Prints the numerical value of the current term's text colour.
Code
print(term.getTextColour())
Output
1
ExampleExampleGet text colour name
Gets the current term's text colour, and then matches it against a lookup table to get its name.
Code
local lookup = { 
    [1] = "white", [2] = "orange", [4] = "magenta", [8] = "lightBlue", 
    [16] = "yellow", [32] = "lime", [64] = "pink", [128] = "gray", 
    [256] = "lightGray",  [512] = "cyan", [1024] = "purple", [2048] = "blue", 
    [4096] = "brown",  [8192] = "green", [16384] = "red", [32768] = "black" 
}
local colour = term.getTextColour()
print(lookup[colour])
Output
white