This commit is contained in:
MihailRis
2024-09-30 13:14:53 +03:00
parent e590d06bb0
commit e30e0083a0
5 changed files with 44 additions and 13 deletions
+2 -1
View File
@@ -212,5 +212,6 @@ void ContentLoader::loadGenerator(
);
}
load_biomes(def, biomesFiles);
def.script = scripting::load_generator(def, scriptFile);
def.script = scripting::load_generator(
def, scriptFile, pack->id+":generators/"+name+".files");
}
+2 -1
View File
@@ -149,7 +149,8 @@ namespace scripting {
std::unique_ptr<GeneratorScript> load_generator(
const GeneratorDef& def,
const fs::path& file
const fs::path& file,
const std::string& dirPath
);
/// @brief Load package-specific world script
@@ -126,12 +126,20 @@ public:
};
std::unique_ptr<GeneratorScript> scripting::load_generator(
const GeneratorDef& def, const fs::path& file
const GeneratorDef& def, const fs::path& file, const std::string& dirPath
) {
auto env = create_environment();
auto L = lua::get_main_thread();
lua::stackguard _(L);
lua::pushenv(L, *env);
lua::pushstring(L, dirPath);
lua::setfield(L, "__DIR__");
lua::pushstring(L, dirPath + "/script.lua");
lua::setfield(L, "__FILE__");
lua::pop(L);
if (fs::exists(file)) {
lua::pop(L, load_script(*env, "generator", file));
} else {