mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
feat: save rules
This commit is contained in:
parent
6602584c13
commit
8c8c844dd4
4 changed files with 47 additions and 13 deletions
|
|
@ -150,7 +150,7 @@ void scripting::initialize(Engine* engine) {
|
|||
void scripting::process_post_runnables() {
|
||||
auto L = lua::get_main_state();
|
||||
if (lua::getglobal(L, "__process_post_runnables")) {
|
||||
lua::call_nothrow(L, 0);
|
||||
lua::call_nothrow(L, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,9 +160,13 @@ void scripting::on_world_load(LevelController* controller) {
|
|||
scripting::indices = level->content->getIndices();
|
||||
scripting::blocks = controller->getBlocksController();
|
||||
scripting::controller = controller;
|
||||
load_script("world.lua", false);
|
||||
|
||||
auto L = lua::get_main_state();
|
||||
if (lua::getglobal(L, "__vc_on_world_open")) {
|
||||
lua::call_nothrow(L, 0, 0);
|
||||
}
|
||||
load_script("world.lua", false);
|
||||
|
||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ":.worldopen");
|
||||
}
|
||||
|
|
@ -180,6 +184,9 @@ void scripting::on_world_save() {
|
|||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ":.worldsave");
|
||||
}
|
||||
if (lua::getglobal(L, "__vc_on_world_save")) {
|
||||
lua::call_nothrow(L, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void scripting::on_world_quit() {
|
||||
|
|
@ -187,6 +194,9 @@ void scripting::on_world_quit() {
|
|||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ":.worldquit");
|
||||
}
|
||||
if (lua::getglobal(L, "__vc_on_world_quit")) {
|
||||
lua::call_nothrow(L, 0, 0);
|
||||
}
|
||||
scripting::level = nullptr;
|
||||
scripting::content = nullptr;
|
||||
scripting::indices = nullptr;
|
||||
|
|
@ -204,11 +214,6 @@ void scripting::cleanup() {
|
|||
}
|
||||
lua::pop(L);
|
||||
|
||||
lua::getglobal(L, "rules");
|
||||
lua::getfield(L, "clear");
|
||||
lua::call_nothrow(L, 0);
|
||||
lua::pop(L);
|
||||
|
||||
if (lua::getglobal(L, "__scripts_cleanup")) {
|
||||
lua::call_nothrow(L, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue