Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:ButtonSetTextureSlice

From RoR Wiki

UI Lua API · Button functions
Version: WAR 1.4.8

Sets the texture a Button draws in one of its states, using a named slice of the texture.

ButtonSetTextureSlice(buttonName, state, textureName, sliceName)

Arguments

buttonName
string – Name of a Button window.
state
number – The button state, a Button.ButtonState value. Fractions are dropped.
textureName
string – Name of the texture.
sliceName
string – Name of a slice defined for that texture.

Returns

Nothing.

Details

  • This is the slice-based counterpart of ButtonSetTexture: the client looks up the position of the slice in the texture and then sets the texture for that state at that position, as ButtonSetTexture does.
  • If the texture or the slice is not found, the button is left unchanged and no error is logged.
  • The stock target frames set the same texture with different slices for the normal and highlighted states (see the example).
  • The function needs at least four arguments and only reads the last four.

Errors

These are written to the UI log; the call returns normally.

  • Error in function call 'ButtonSetTextureSlice': Window %s does not exist
  • Error in function call 'ButtonSetTextureSlice': Window %s is not a Button

Example

From eatemplate_unitframes/source/targetunitframe.lua:

ButtonSetTextureSlice(buttonName, Button.ButtonState.NORMAL, "EA_HUD_01", normalSlice);
ButtonSetTextureSlice(buttonName, Button.ButtonState.HIGHLIGHTED, "EA_HUD_01", rolloverSlice);
ButtonSetTextureSlice(buttonName, Button.ButtonState.PRESSED, "EA_HUD_01", normalSlice);
ButtonSetTextureSlice(buttonName, Button.ButtonState.PRESSED_HIGHLIGHTED, "EA_HUD_01", rolloverSlice);

See also