term.getBackgroundColour

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

ExampleGet background colour
Prints the numerical value of the current term's background colour.
Code
<nowiki>
print(term.getBackgroundColour())
  </nowiki>
Output
32768
ExampleGet background colour name
Gets the current term's background colour, and then matches it against a lookup table to get its name.
Code
<nowiki>
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.getBackgroundColour()
print(lookup[colour])
  </nowiki>
Output
black

term.getBackgroundColour
Function
Syntax
term.getBackgroundColour()
Returns number colour
API term
Source CC:Tweaked (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.