aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_client.cpp
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-05-06 20:12:44 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-05-06 21:12:44 +0200
commit5ebf8f945050e9c74a3bb6784a0844d1fb68bdff (patch)
tree474c9f798c7624c659dd16aa11a4d097cd16b5b4 /src/script/cpp_api/s_client.cpp
parent6658ad3d94c053eeed12bb79e255cdfa46831e19 (diff)
downloadminetest-5ebf8f945050e9c74a3bb6784a0844d1fb68bdff.tar.gz
minetest-5ebf8f945050e9c74a3bb6784a0844d1fb68bdff.tar.bz2
minetest-5ebf8f945050e9c74a3bb6784a0844d1fb68bdff.zip
[CSM] add `on_item_use` (#5544)
Diffstat (limited to 'src/script/cpp_api/s_client.cpp')
-rw-r--r--src/script/cpp_api/s_client.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp
index 4bc368d1d..d5ec52407 100644
--- a/src/script/cpp_api/s_client.cpp
+++ b/src/script/cpp_api/s_client.cpp
@@ -207,6 +207,23 @@ bool ScriptApiClient::on_placenode(const PointedThing &pointed, const ItemDefini
return lua_toboolean(L, -1);
}
+bool ScriptApiClient::on_item_use(const ItemStack &item, const PointedThing &pointed)
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ // Get core.registered_on_item_use
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_item_use");
+
+ // Push data
+ LuaItemStack::create(L, item);
+ push_pointed_thing(L, pointed);
+
+ // Call functions
+ runCallbacks(2, RUN_CALLBACKS_MODE_OR);
+ return lua_toboolean(L, -1);
+}
+
void ScriptApiClient::setEnv(ClientEnvironment *env)
{
ScriptApiBase::setEnv(env);