fix: pack environment not passed to components

This commit is contained in:
MihailRis
2025-12-08 19:21:49 +03:00
committed by ShiftyX1
parent 59df377fde
commit 5ae34c2dc2
4 changed files with 19 additions and 4 deletions
+9 -1
View File
@@ -1,6 +1,7 @@
#include "libentity.hpp"
#include "content/Content.hpp"
#include "content/ContentPack.hpp"
#include "engine/Engine.hpp"
#include "engine/EnginePaths.hpp"
#include "objects/Entities.hpp"
@@ -236,7 +237,14 @@ static int l_reload_component(lua::State* L) {
}
auto filename = name.substr(0, pos + 1) + "scripts/components/" +
name.substr(pos + 1) + ".lua";
scripting::load_entity_component(name, filename, filename);
auto prefix = name.substr(0, pos);
auto runtime = content->getPackRuntime(prefix);
if (runtime == nullptr) {
throw std::runtime_error("pack '" + prefix + "' content is not loaded");
}
scripting::load_entity_component(
runtime->getEnvironment(), name, filename, filename
);
return 0;
}