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
@@ -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 {