fix: commands repository not reset before world open
This commit is contained in:
@@ -362,6 +362,7 @@ void Engine::loadContent() {
|
|||||||
load_configs(pack.folder);
|
load_configs(pack.folder);
|
||||||
}
|
}
|
||||||
content = contentBuilder.build();
|
content = contentBuilder.build();
|
||||||
|
interpreter->reset();
|
||||||
scripting::on_content_load(content.get());
|
scripting::on_content_load(content.get());
|
||||||
|
|
||||||
ContentLoader::loadScripts(*content);
|
ContentLoader::loadScripts(*content);
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ namespace cmd {
|
|||||||
const std::unordered_map<std::string, Command>& getCommands() const {
|
const std::unordered_map<std::string, Command>& getCommands() const {
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
commands.clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CommandsInterpreter {
|
class CommandsInterpreter {
|
||||||
@@ -158,5 +162,10 @@ namespace cmd {
|
|||||||
CommandsRepository* getRepository() const {
|
CommandsRepository* getRepository() const {
|
||||||
return repository.get();
|
return repository.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
repository->clear();
|
||||||
|
variables.clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ void scripting::initialize(Engine* engine) {
|
|||||||
lua::initialize(*engine->getPaths());
|
lua::initialize(*engine->getPaths());
|
||||||
|
|
||||||
load_script(fs::path("stdlib.lua"), true);
|
load_script(fs::path("stdlib.lua"), true);
|
||||||
load_script(fs::path("stdcmd.lua"), true);
|
|
||||||
load_script(fs::path("classes.lua"), true);
|
load_script(fs::path("classes.lua"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,6 +171,7 @@ void scripting::on_content_load(Content* content) {
|
|||||||
lua::setfield(L, "materials");
|
lua::setfield(L, "materials");
|
||||||
lua::pop(L);
|
lua::pop(L);
|
||||||
}
|
}
|
||||||
|
load_script(fs::path("stdcmd.lua"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scripting::on_world_load(LevelController* controller) {
|
void scripting::on_world_load(LevelController* controller) {
|
||||||
|
|||||||
Reference in New Issue
Block a user