From 073f5cf03d95ce1cdf04ce8a0adcaf1fc571d95f Mon Sep 17 00:00:00 2001 From: red-001 Date: Sun, 29 Jan 2017 17:43:44 +0000 Subject: [CSM] Add `on_dignode` callback (#5140) --- src/script/cpp_api/s_client.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/script/cpp_api/s_client.cpp') diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp index 1827d483b..2c8fee334 100644 --- a/src/script/cpp_api/s_client.cpp +++ b/src/script/cpp_api/s_client.cpp @@ -21,6 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "s_client.h" #include "s_internal.h" #include "client.h" +#include "common/c_converter.h" +#include "common/c_content.h" void ScriptApiClient::on_shutdown() { @@ -136,3 +138,23 @@ void ScriptApiClient::on_formspec_input(const std::string &formname, } runCallbacks(2, RUN_CALLBACKS_MODE_OR_SC); } + +bool ScriptApiClient::on_dignode(v3s16 p, MapNode node) +{ + SCRIPTAPI_PRECHECKHEADER + + INodeDefManager *ndef = getClient()->ndef(); + + // Get core.registered_on_dignode + lua_getglobal(L, "core"); + lua_getfield(L, -1, "registered_on_dignode"); + + // 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; +} \ No newline at end of file -- cgit v1.2.3