Textures
A global API which allows for creating textures at runtime
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:
Type | Description |
---|---|
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:
Name | Type | Description | Default |
---|---|---|---|
name | String | - | - |
Returns:
Type | Description |
---|---|
Texture | - |
Example:
textures:get("Name")
copy()
Creates a copy of the texture
The copy is registered with the given name
copy(name, texture)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | String | - | - |
texture | Texture | - | - |
Returns:
Type | Description |
---|---|
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:
Name | Type | Description | Default |
---|---|---|---|
name | String | - | - |
path | String | - | - |
Returns:
Type | Description |
---|---|
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:
Name | Type | Description | Default |
---|---|---|---|
name | String | - | - |
width | Integer | - | - |
height | Integer | - | - |
Returns:
Type | Description |
---|---|
Texture | - |
Example:
textures:newTexture("Name", 64, 64)
read()
Reads a texture from a base64 string or a byte array
- Overload 1
- Overload 2
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)