More actions
don't show hatnote when tx'd Tag: 2017 source edit |
new tutorial i guess Tag: 2017 source edit |
||
Line 16: | Line 16: | ||
}} | }} | ||
{{tree|icon=BBCube.png|content=Cool Name}} | {{tree|icon=BBCube.png|content=Cool Name}} | ||
{{tree|icon=BBGroup.png|content=Cool Group|inner= | |||
{{tree|icon=BBCube.png|content=cube}} | |||
}} | |||
}} | }} | ||
}} | }} | ||
Line 21: | Line 24: | ||
To access a child part, ''index'' the parent part with the name of the child part. | To access a child part, ''index'' the parent part with the name of the child part. | ||
There are two ways to ''index'' something in Lua. The first way is by using | There are two ways to ''index'' something in Lua. The first way is by using dots: | ||
<div style="padding: 4px 6px; border-radius: 6px; border: 3px solid var(--color-success); width: fit-content; margin-top: 6px;"><code>models.model.root.Head</code></div> | |||
This code sample first gets the <code>model</code> part (a file named <code>model.bbmodel</code>) and then the <code>Head</code> group inside it. The name of the cube, mesh, group, folder, or file needs to be within the quotes. To access deeper parts (for example, a <code>HeadLayer</code> cube within the <code>Head</code> group), add more dots and names: | |||
<div style="padding: 4px 6px; border-radius: 6px; border: 3px solid var(--color-success); width: fit-content; margin-top: 6px;"><code>models.model.root.HeadLayer</code></div> | |||
< | The second way to index is longer, and uses square brackets and quotes (<code>[""]</code>) to separate the names. '''This method is required if the name of a part contains characters that aren't letters, numbers, or underscores'''; this includes ''names with spaces'', like <code>Right Arm</code>. | ||
</ | |||
When using brackets to index, place the name '''between the quotes''', and '''don't include a period before it''': | |||
* <div style="padding: 3px 4px; border-radius: 4px; border: 2px solid var(--color-success); width: fit-content; margin-top: 6px;"><code>models["model"]["root"]["Cool Name"]</code> ✓ Correct</div> | |||
* <div style="padding: 3px 4px; border-radius: 4px; border: 2px solid var(--color-success); width: fit-content; margin-top: 6px;"><code>models.model.root["Cool Name"]</code> ✓ Correct - both brackets and dots can be mixed together!</div> | |||
* <div style="padding: 3px 4px; border-radius: 4px; border: 2px solid var(--color-destructive); width: fit-content; margin-top: 6px;"><code>models.model.root.["Cool Name"]</code> ✗ Incorrect: '''don't put a dot <code>.</code> before the bracket <code>[</code>.'''</div> | |||
* <div style="padding: 3px 4px; border-radius: 4px; border: 2px solid var(--color-destructive); width: fit-content; margin-top: 6px;"><code>models.model.root[Cool Name]</code> ✗ Incorrect: '''name in brackets is missing a set of quotes'''</div> | |||
< | To return to using dots for indexing after using brackets, place the dot after the closing bracket: | ||
models.model.root["Cool | * <div style="padding: 3px 4px; border-radius: 4px; border: 2px solid var(--color-success); width: fit-content; margin-top: 6px;"><code>models.model.root["Cool Group"].cube</code> ✓ Correct</div> | ||
</ | * <div style="padding: 3px 4px; border-radius: 4px; border: 2px solid var(--color-destructive); width: fit-content; margin-top: 6px;"><code>models.model.root["Cool Group"]cube</code> ✗ Incorrect: '''missing dot <code>.</code> after bracket'''<div> | ||
=== A note on model files in folders === | === A note on model files in folders === |
Latest revision as of 05:40, 27 March 2025
When Figura loads your avatar, all the model files in your avatar are organized into a tree. The starting point of this tree is called models
. All of the parts of your model, including cubes, meshes, and groups from your Blockbench models, as well as folders in your avatar and the model files themselves are converted to ModelParts and part of this tree.
The name models
does not refer to any specific model file in your avatar. Instead, model files are created as children of the models
folder. If your Blockbench model is inside a subfolder of your avatar, that folder becomes a child of models
, and the model file becomes a child of the subfolder.

model.bbmodel










To access a child part, index the parent part with the name of the child part.
There are two ways to index something in Lua. The first way is by using dots:
models.model.root.Head
This code sample first gets the model
part (a file named model.bbmodel
) and then the Head
group inside it. The name of the cube, mesh, group, folder, or file needs to be within the quotes. To access deeper parts (for example, a HeadLayer
cube within the Head
group), add more dots and names:
models.model.root.HeadLayer
The second way to index is longer, and uses square brackets and quotes ([""]
) to separate the names. This method is required if the name of a part contains characters that aren't letters, numbers, or underscores; this includes names with spaces, like Right Arm
.
When using brackets to index, place the name between the quotes, and don't include a period before it:
models["model"]["root"]["Cool Name"]
✓ Correctmodels.model.root["Cool Name"]
✓ Correct - both brackets and dots can be mixed together!models.model.root.["Cool Name"]
✗ Incorrect: don't put a dot.
before the bracket[
.models.model.root[Cool Name]
✗ Incorrect: name in brackets is missing a set of quotes
To return to using dots for indexing after using brackets, place the dot after the closing bracket:
models.model.root["Cool Group"].cube
✓ Correctmodels.model.root["Cool Group"]cube
✗ Incorrect: missing dot.
after bracket
A note on model files in folders
If your Blockbench model file is within a folder in your avatar, the folder will become a part of the ModelPart tree. That means that if a model file named player.bbmodel
is located in a folder named models
, the model file has to be accessed with models.models.player
(or models["models"]["player"]
.)
If you later want to use animations from a model, folders affect the indexing into the animations
table too - but the system is a little different.
Instead of indexing the folder and then the file, combine each folder name and the file name with a period .
and index with the combined name, even if the names of the folders and files contain special characters. For example, to get the animations from the model 2.bbmodel
file in the main models
folder:

main models

model 2.bbmodel
animations["main models.model 2"]