Open VideoGames1000 opened 2 months ago
You can tell Figura to load files in the avatar's folder with the resources
key in the avatar.json
metadata. This will cause the files to be uploaded with the avatar so they can be used almost like normal.
resources
is a list of file globs.
{
"resources": [
"*.res.png", // Loads any file with the extension `.res.png` in the avatar root.
"**/icon.png", // Loads any file called `icon.png` in any subfolder of the avatar.
"etc."
]
}
These resources can then be loaded with the Resources API.
Can you give a practical example for the resource API part? Specifically, I'm trying to make radialmenu icons with this, if that helps.
local buffer = data:createBuffer()
buffer:readFromStream(resources:get("path/to/file.png")) -- File path starts at avatar's root folder.
buffer:setPosition(0)
local newTexture = textures:read("newTextureName", buffer:readBase64(buffer:getLength()))
buffer:close()
-- After this, any function can reference `newTexture` as the texture to use.
It's not exactly the most pretty thing because you have to deal with Figura's (imo annoying) file IO implementation.
Request Description
Simply, allow
textures:get()
to pull from a .png file in the Avatar's folder instead of needing to be embedded in a blockbench model or encoded. It's a small change on the user end, but it'd be a nice touch for my personal use case.