Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

Changes the texture of a texture object.

texture:SetTexture("filename"[, tile]);
texture:SetTexture(r, g, b[, a]);

Arguments

filename [,tile]

filename
String - Name of the texture image. Images may be in BLP or TGA format, and must have power-of-two dimensions up to 1024 pixels. TGA images may have 8, 24, or 32 bits per pixel for grayscale, RGB, and RGBA images respectively; RLE is supported.
tile
Boolean flag - Tile the image if the coordinates set using Texture:SetTexCoord exceed the 0.0-1.0 range.

r, g, b, a

r
Number (0.0 to 1.0) - Red component.
g
Number (0.0 to 1.0) - Green component.
b
Number (0.0 to 1.0) - Blue component.
a
Number (0.0 to 1.0) - Alpha component (1.0 is opaque, 0.0 is transparent). The default value is 1.0.

Returns

Prior to patch 4.0, this would return nil if the texture could not be loaded and 1 if the texture was successfully loaded. This appears to now be broken and will always return 1 even upon failure. A workaround for finding out if the texture was loaded successfully is to immediately call Texture:GetTexture after loading, which will return nil if the texture failed to load.

Description

Can be used to either set the texture file, or to change the RGB fill of a texture. Pass it one string to change the texture file, or pass it three numbers to set the RGB. The only place I've seen this used to change the color is within the inline script of a ColorSelect object.

Notes

  • If no image is shown, the game will not find image files that did not exist when it was started, you may need to restart the game for the texture to appear.
  • The texture has to be cleared or set to solid colour, or anyway changed away from the current file, before tiling can be changed. Hence the following code will fail:
texture:SetTexture("image.tga",true)
texture:SetTexture("image.tga",false)
Advertisement