term.getBackgroundColor

From ComputerCraft Wiki
Revision as of 12:18, 28 June 2015 by MKlegoman357 (Talk | contribs) (Created page with "{{Lowercase}} {{Function |name=term.getBackgroundColor |args= |returns={{type|number}} color code |api=term |addon=ComputerCraft |desc=Gets the current background color of the...")

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


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


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

Examples

Grid paper.png  Example
Prints the current background color of the terminal.
Code
local currentBackgroundColor = term.getBackgroundColor()

print( "The current background color is: ", currentBackgroundColor )



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

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

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