lua: on_block_interact prevent default feature

This commit is contained in:
MihailRis
2024-01-29 01:37:40 +03:00
parent f49aa9eab0
commit 7df98f7b35
3 changed files with 8 additions and 5 deletions
+5 -2
View File
@@ -181,12 +181,15 @@ void scripting::on_block_broken(Player* player, const Block* block, int x, int y
call_func(L, 4, name);
}
void scripting::on_block_interact(Player* player, const Block* block, int x, int y, int z) {
bool scripting::on_block_interact(Player* player, const Block* block, int x, int y, int z) {
std::string name = block->name+".oninteract";
lua_getglobal(L, name.c_str());
lua_pushivec3(L, x, y, z);
lua_pushinteger(L, 1);
call_func(L, 4, name);
if (call_func(L, 4, name)) {
return lua_toboolean(L, -1);
}
return false;
}
bool scripting::on_item_use_on_block(Player* player, const ItemDef* item, int x, int y, int z) {