add 'on_block_removed' event

This commit is contained in:
MihailRis
2025-11-18 22:11:44 +03:00
parent b3e5f2a1c0
commit f721731ecc
12 changed files with 61 additions and 16 deletions
+1
View File
@@ -119,6 +119,7 @@ static int l_close_world(lua::State* L) {
if (controller == nullptr) {
throw std::runtime_error("no world open");
}
controller->processBeforeQuit();
bool save_world = lua::toboolean(L, 1);
if (save_world) {
controller->saveWorld();
+9
View File
@@ -341,6 +341,13 @@ void scripting::on_world_save() {
}
}
void scripting::process_before_quit() {
auto L = lua::get_main_state();
if (lua::getglobal(L, "__vc_process_before_quit")) {
lua::call_nothrow(L, 0, 0);
}
}
void scripting::on_world_quit() {
auto L = lua::get_main_state();
for (auto& pack : content_control->getAllContentPacks()) {
@@ -677,6 +684,8 @@ void scripting::load_content_script(
register_event(env, "on_blocks_tick", prefix + ".blockstick");
funcsset.onblockpresent =
register_event(env, "on_block_present", prefix + ".blockpresent");
funcsset.onblockremoved =
register_event(env, "on_block_removed", prefix + ".blockremoved");
}
void scripting::load_content_script(
+1
View File
@@ -81,6 +81,7 @@ namespace scripting {
void on_world_load(LevelController* controller);
void on_world_tick(int tps);
void on_world_save();
void process_before_quit();
void on_world_quit();
void cleanup(const std::vector<std::string>& nonReset);
void on_blocks_tick(const Block& block, int tps);