1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

[CSM] Add on_punchnode callback

This commit is contained in:
red-001 2017-01-29 18:28:38 +00:00 committed by Loïc Blot
parent 37df9cb7d7
commit 0727bb3ddd
6 changed files with 48 additions and 13 deletions

View file

@ -157,4 +157,24 @@ bool ScriptApiClient::on_dignode(v3s16 p, MapNode node)
runCallbacks(2, RUN_CALLBACKS_MODE_OR);
bool blocked = lua_toboolean(L, -1);
return blocked;
}
}
bool ScriptApiClient::on_punchnode(v3s16 p, MapNode node)
{
SCRIPTAPI_PRECHECKHEADER
INodeDefManager *ndef = getClient()->ndef();
// Get core.registered_on_punchgnode
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_punchnode");
// Push data
push_v3s16(L, p);
pushnode(L, node, ndef);
// Call functions
runCallbacks(2, RUN_CALLBACKS_MODE_OR);
bool blocked = lua_toboolean(L, -1);
return blocked;
}