FiguraMC / Figura

Extensively customize your character with Figura!
https://modrinth.com/mod/figura
GNU Lesser General Public License v2.1
224 stars 44 forks source link

Script storage and require overhaul #135

Closed KitCat962 closed 9 months ago

KitCat962 commented 9 months ago

Optimizes the Avatar nbt by saving scripts as a Compound Tag mimiking the file structure instead of repeating the path per script. Additionally, it updates the /figura debug command to reflect these changes

This is the nbt pre-optimization image

This is the nbt post-optimization image

Additionally, all internals now expect the file separator to be /.

require and listFiles now accept relative file paths via . and .. A path is relative to root if it starts with a . /a and a both point to the root a.lua while ./a points to a.lua in the same folder as the executing script

For this folder structure...

folder
- folderB
- - innerScript.lua
- script.lua
- require.lua
script.lua
-- folder/require.lua

require("script") --> script.lua
require("./script") --> folder/script.lua
require("./folderB") --> 'Tried to require nonexistent script "folder/folderB"!'
require("../script") --> script.lua
require("folderB/innerScript") --> 'Tried to require nonexistent script "folderB/innerScript"!'
require("./folderB/innerScript") --> folder/folderB/innerScript.lua
require("../folder/folderB/./././../folderB/../../script") --> script.lua
KitCat962 commented 9 months ago

new tech just dropped. Dont merge

KitCat962 commented 9 months ago

New tech implemented. Ready for merge