summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_client.cpp
diff options
context:
space:
mode:
authorVincent Glize <vincentglize@hotmail.fr>2017-04-29 12:08:16 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-04-29 12:08:16 +0200
commitdc5bc6cac7b81ab27e0064bc25b5fd1d8d617340 (patch)
tree5b7be08157b8c377dfd10152c04d44687e9b1c81 /src/script/cpp_api/s_client.cpp
parentecf08255b0b6b9d15b86f614942ac8f53f41302a (diff)
downloadminetest-dc5bc6cac7b81ab27e0064bc25b5fd1d8d617340.tar.gz
minetest-dc5bc6cac7b81ab27e0064bc25b5fd1d8d617340.tar.bz2
minetest-dc5bc6cac7b81ab27e0064bc25b5fd1d8d617340.zip
[CSM] Add event on_place_node API lua (#5548)
* [CSM] Add event on_place_node API lua
Diffstat (limited to 'src/script/cpp_api/s_client.cpp')
-rw-r--r--src/script/cpp_api/s_client.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp
index a8a7d5e26..4bc368d1d 100644
--- a/src/script/cpp_api/s_client.cpp
+++ b/src/script/cpp_api/s_client.cpp
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client.h"
#include "common/c_converter.h"
#include "common/c_content.h"
+#include "s_item.h"
void ScriptApiClient::on_shutdown()
{
@@ -189,6 +190,23 @@ bool ScriptApiClient::on_punchnode(v3s16 p, MapNode node)
return blocked;
}
+bool ScriptApiClient::on_placenode(const PointedThing &pointed, const ItemDefinition &item)
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ // Get core.registered_on_placenode
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_placenode");
+
+ // Push data
+ push_pointed_thing(L, pointed);
+ push_item_definition(L, item);
+
+ // Call functions
+ runCallbacks(2, RUN_CALLBACKS_MODE_OR);
+ return lua_toboolean(L, -1);
+}
+
void ScriptApiClient::setEnv(ClientEnvironment *env)
{
ScriptApiBase::setEnv(env);