Skip to main content

Textures

A global API which allows for creating textures at runtime

warning

This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.


getTextures()

Returns a table with all textures used by this avatar's Blockbench models

Does not include generated textures from this API

getTextures()

Returns:

TypeDescription
Table-

Example:

logTable(textures:getTextures())

get()

Gets a registered texture based on its name, or nil if no texture was found with that name

get(name)

Parameters:

NameTypeDescriptionDefault
nameString--

Returns:

TypeDescription
Texture-

Example:

textures:get("Name")

copy()

Creates a copy of the texture

The copy is registered with the given name

copy(name, texture)

Parameters:

NameTypeDescriptionDefault
nameString--
textureTexture--

Returns:

TypeDescription
Texture-

Example:

textures:copy("Name", textures["myTexture"])

fromVanilla()

Returns a copy of a resource texture as a texture object for modifying

fromVanilla(name, path)

Parameters:

NameTypeDescriptionDefault
nameString--
pathString--

Returns:

TypeDescription
Texture-

Example:

textures:fromVanilla("Name", "textures/item/apple.png")

newTexture()

Creates a new texture with the given name, width and height

The texture is filled with a solid color

newTexture(name, width, height)

Parameters:

NameTypeDescriptionDefault
nameString--
widthInteger--
heightInteger--

Returns:

TypeDescription
Texture-

Example:

textures:newTexture("Name", 64, 64)

read()

Reads a texture from a base64 string or a byte array

read(name, base64Text)

Parameters:

NameTypeDescriptionDefault
nameString--
base64TextString--

Returns:

TypeDescription
Texture-

Example:

-- Reads a texture stored in an item's name...
local page = action_wheel:newPage()
action_wheel:setPage(page)
page:newAction()
:onLeftClick(function()
local base64 = parseJson(player:getItem(1):getTag().display.Name).text
local tex = textures:read('tex', base64)
models.myModel:setPrimaryTexture('custom', tex)
end)