More actions
m PenguinEncounter moved page User:PenguinEncounter/ModelPart Indexing to ModelPart Indexing: Publishing page |
don't show hatnote when tx'd Tag: 2017 source edit |
||
Line 1: | Line 1: | ||
{{Hatnote|For technical documentation on ModelParts, see [[ModelPart]].}} | <noinclude>{{Hatnote|For technical documentation on ModelParts, see [[ModelPart]].}}</noinclude> | ||
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 <code>models</code>. 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. | 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 <code>models</code>. 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. |
Latest revision as of 06:45, 25 January 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 brackets and quotes:
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 indexing:
models["model"]["root"]["Head"]["HeadLayer"]
The second way to index is shorter, and uses a .
to separate the names.
This method only works if the name consists only of letters, numbers, and underscores and the first character isn't a number. If the name of a ModelPart contains characters not in that list, or if the name contains any spaces, you must use the first method to index that name.
For example, the following is equivalent to the code above for getting the Hat
ModelPart.
models.model.root.Head.HeadLayer
However, to access the cube named Cool Name
, you have to use the square brackets. The two methods can be mixed together:
models.model.root["Cool Name"]
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"]