update events & update some built-in events codes
This commit is contained in:
@@ -164,32 +164,32 @@ void scripting::on_world_load(LevelController* controller) {
|
||||
|
||||
auto L = lua::get_main_state();
|
||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ".worldopen");
|
||||
lua::emit_event(L, pack.id + ":.worldopen");
|
||||
}
|
||||
}
|
||||
|
||||
void scripting::on_world_tick() {
|
||||
auto L = lua::get_main_state();
|
||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ".worldtick");
|
||||
lua::emit_event(L, pack.id + ":.worldtick");
|
||||
}
|
||||
}
|
||||
|
||||
void scripting::on_world_save() {
|
||||
auto L = lua::get_main_state();
|
||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ".worldsave");
|
||||
lua::emit_event(L, pack.id + ":.worldsave");
|
||||
}
|
||||
}
|
||||
|
||||
void scripting::on_world_quit() {
|
||||
auto L = lua::get_main_state();
|
||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ".worldquit");
|
||||
lua::emit_event(L, pack.id + ":.worldquit");
|
||||
}
|
||||
|
||||
lua::getglobal(L, "pack");
|
||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||
for (auto& pack : scripting::engine->getAllContentPacks()) {
|
||||
lua::getfield(L, "unload");
|
||||
lua::pushstring(L, pack.id);
|
||||
lua::call_nothrow(L, 1);
|
||||
@@ -248,7 +248,7 @@ void scripting::on_block_placed(
|
||||
if (pack->worldfuncsset.onblockplaced) {
|
||||
lua::emit_event(
|
||||
lua::get_main_state(),
|
||||
packid + ".blockplaced",
|
||||
packid + ":.blockplaced",
|
||||
world_event_args
|
||||
);
|
||||
}
|
||||
@@ -280,7 +280,7 @@ void scripting::on_block_broken(
|
||||
if (pack->worldfuncsset.onblockbroken) {
|
||||
lua::emit_event(
|
||||
lua::get_main_state(),
|
||||
packid + ".blockbroken",
|
||||
packid + ":.blockbroken",
|
||||
world_event_args
|
||||
);
|
||||
}
|
||||
@@ -686,14 +686,14 @@ void scripting::load_world_script(
|
||||
int env = *senv;
|
||||
lua::pop(lua::get_main_state(), load_script(env, "world", file));
|
||||
register_event(env, "init", prefix + ".init");
|
||||
register_event(env, "on_world_open", prefix + ".worldopen");
|
||||
register_event(env, "on_world_tick", prefix + ".worldtick");
|
||||
register_event(env, "on_world_save", prefix + ".worldsave");
|
||||
register_event(env, "on_world_quit", prefix + ".worldquit");
|
||||
register_event(env, "on_world_open", prefix + ":.worldopen");
|
||||
register_event(env, "on_world_tick", prefix + ":.worldtick");
|
||||
register_event(env, "on_world_save", prefix + ":.worldsave");
|
||||
register_event(env, "on_world_quit", prefix + ":.worldquit");
|
||||
funcsset.onblockplaced =
|
||||
register_event(env, "on_block_placed", prefix + ".blockplaced");
|
||||
register_event(env, "on_block_placed", prefix + ":.blockplaced");
|
||||
funcsset.onblockbroken =
|
||||
register_event(env, "on_block_broken", prefix + ".blockbroken");
|
||||
register_event(env, "on_block_broken", prefix + ":.blockbroken");
|
||||
}
|
||||
|
||||
void scripting::load_layout_script(
|
||||
|
||||
Reference in New Issue
Block a user