aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-01-29 18:28:38 +0000
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-03-13 23:56:05 +0100
commit0727bb3ddd9c550ff962af4546bac8cc058bce73 (patch)
treeca5a815f5f30883fe8a9b016db5b706486596714 /src/script/cpp_api
parent37df9cb7d764891f29b433e80a0d5663fee1a94f (diff)
downloadminetest-0727bb3ddd9c550ff962af4546bac8cc058bce73.tar.gz
minetest-0727bb3ddd9c550ff962af4546bac8cc058bce73.tar.bz2
minetest-0727bb3ddd9c550ff962af4546bac8cc058bce73.zip
[CSM] Add `on_punchnode` callback
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r--src/script/cpp_api/s_client.cpp22
-rw-r--r--src/script/cpp_api/s_client.h1
2 files changed, 22 insertions, 1 deletions
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp
index 2c8fee334..8c5e3796b 100644
--- a/src/script/cpp_api/s_client.cpp
+++ b/src/script/cpp_api/s_client.cpp
@@ -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;
-} \ No newline at end of file
+}
+
+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;
+}
diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h
index 09fd3a691..93e9558f2 100644
--- a/src/script/cpp_api/s_client.h
+++ b/src/script/cpp_api/s_client.h
@@ -46,5 +46,6 @@ public:
void on_formspec_input(const std::string &formname, const StringMap &fields);
bool on_dignode(v3s16 p, MapNode node);
+ bool on_punchnode(v3s16 p, MapNode node);
};
#endif