API:LabelGetTextColor
From RoR Wiki
UI Lua API · Label functions
Version: WAR 1.4.8
Defined in Lua: interfacecore/source/windowstate.lua
Returns the text colour of a Label.
r, g, b = LabelGetTextColor(labelName)
Arguments
- labelName
string– Name of a Label window.
Returns
- r, g, b
number– Red, green and blue. From the client function these are on a 0–255 scale. See Details for the cached case.
Details
- The client registers the C function as
_LabelGetTextColor. TheLabelGetTextColorthat addons call is a Lua function defined ininterfacecore/source/windowstate.lua:- If the global table named after the window (
_G[labelName]) has aSTATEtable, it returnsSTATE.LABEL_TEXTCOLOR_R,STATE.LABEL_TEXTCOLOR_GandSTATE.LABEL_TEXTCOLOR_Bwithout calling into the client. - Otherwise it calls
_LabelGetTextColor(labelName).
- If the global table named after the window (
_LabelGetTextColorreturns the stored colour multiplied by 255. The alpha channel is not returned.- The values the client writes to
STATE.LABEL_TEXTCOLOR_R/G/Bare the stored colour on a 0–1 scale, not multiplied by 255. A label with aSTATEtable therefore gives values 255 times smaller than one without. - LabelSetTextColor writes the new colour to
STATE.TEXTCOLOR_R/G/B(noLABEL_prefix), keys the wrapper does not read. - LabelGetLinkColor is a Lua wrapper that calls this function.
Errors
Raised by _LabelGetTextColor:
Error in function call 'LabelGetTextColor': Window %s does not existError in function call 'LabelGetTextColor': Window %s is not a Label
Example
Remembering a label's XML colour before changing it, from ea_interactionwindow/source/interactionwindowlibrarian.lua:
local red, green, blue = LabelGetTextColor( "EA_Window_InteractionLibrarianStoreFilterByUsableLabel" )
EA_Window_InteractionLibrarianStore.ENABLED_FILTER_COLOR = {r=red,g=green,b=blue}
EA_Window_InteractionLibrarianStore.DISABLED_FILTER_COLOR = {r=128,g=128,b=128}
