mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
feat: world script reloading
This commit is contained in:
parent
bcbfdd50c7
commit
f9998f0a93
10 changed files with 56 additions and 13 deletions
|
|
@ -889,6 +889,21 @@ void ContentLoader::reloadScript(const Content& content, ItemDef& item) {
|
|||
load_script(content, item);
|
||||
}
|
||||
|
||||
void ContentLoader::loadWorldScript(ContentPackRuntime& runtime) {
|
||||
const auto& pack = runtime.getInfo();
|
||||
const auto& folder = pack.folder;
|
||||
io::path scriptFile = folder / "scripts/world.lua";
|
||||
if (io::is_regular_file(scriptFile)) {
|
||||
scripting::load_world_script(
|
||||
runtime.getEnvironment(),
|
||||
pack.id,
|
||||
scriptFile,
|
||||
pack.id + ":scripts/world.lua",
|
||||
runtime.worldfuncsset
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::loadScripts(Content& content) {
|
||||
load_scripts(content, content.blocks);
|
||||
load_scripts(content, content.items);
|
||||
|
|
@ -898,16 +913,8 @@ void ContentLoader::loadScripts(Content& content) {
|
|||
const auto& folder = pack.folder;
|
||||
|
||||
// Load main world script
|
||||
io::path scriptFile = folder / "scripts/world.lua";
|
||||
if (io::is_regular_file(scriptFile)) {
|
||||
scripting::load_world_script(
|
||||
runtime->getEnvironment(),
|
||||
pack.id,
|
||||
scriptFile,
|
||||
pack.id + ":scripts/world.lua",
|
||||
runtime->worldfuncsset
|
||||
);
|
||||
}
|
||||
loadWorldScript(*runtime);
|
||||
|
||||
// Load entity components
|
||||
io::path componentsDir = folder / "scripts/components";
|
||||
foreach_file(componentsDir, [&pack](const io::path& file) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue