Skip to content

Return of Reckoning

Wiki

RoR Wiki

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. The LabelGetTextColor that addons call is a Lua function defined in interfacecore/source/windowstate.lua:
    • If the global table named after the window (_G[labelName]) has a STATE table, it returns STATE.LABEL_TEXTCOLOR_R, STATE.LABEL_TEXTCOLOR_G and STATE.LABEL_TEXTCOLOR_B without calling into the client.
    • Otherwise it calls _LabelGetTextColor(labelName).
  • _LabelGetTextColor returns the stored colour multiplied by 255. The alpha channel is not returned.
  • The values the client writes to STATE.LABEL_TEXTCOLOR_R/G/B are the stored colour on a 0–1 scale, not multiplied by 255. A label with a STATE table therefore gives values 255 times smaller than one without.
  • LabelSetTextColor writes the new colour to STATE.TEXTCOLOR_R/G/B (no LABEL_ 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 exist
  • Error 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}

See also