aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-11-30 20:54:54 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-30 20:54:54 +0200
commitcd563473fa298db3b910009f26ba263bacd84be9 (patch)
tree8997c54845dd9b2e2a9e03ef9937bea75c1b859f /src
parentd26e19a296e049085bf56ca09c5b8ae26d32524d (diff)
downloadminetest-cd563473fa298db3b910009f26ba263bacd84be9.tar.gz
minetest-cd563473fa298db3b910009f26ba263bacd84be9.tar.bz2
minetest-cd563473fa298db3b910009f26ba263bacd84be9.zip
Add ObjectRef:punch and ObjectRef:right_click to Lua API
Diffstat (limited to 'src')
-rw-r--r--src/scriptapi.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index fbdbf4a12..8a3d4a496 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -1642,6 +1642,34 @@ private:
return 0;
}
+ // punch(self, puncher); puncher = an another ObjectRef
+ static int l_punch(lua_State *L)
+ {
+ ObjectRef *ref = checkobject(L, 1);
+ ObjectRef *ref2 = checkobject(L, 2);
+ ServerActiveObject *co = getobject(ref);
+ ServerActiveObject *co2 = getobject(ref2);
+ if(co == NULL) return 0;
+ if(co2 == NULL) return 0;
+ // Do it
+ co->punch(co2);
+ return 0;
+ }
+
+ // right_click(self, clicker); clicker = an another ObjectRef
+ static int l_right_click(lua_State *L)
+ {
+ ObjectRef *ref = checkobject(L, 1);
+ ObjectRef *ref2 = checkobject(L, 2);
+ ServerActiveObject *co = getobject(ref);
+ ServerActiveObject *co2 = getobject(ref2);
+ if(co == NULL) return 0;
+ if(co2 == NULL) return 0;
+ // Do it
+ co->rightClick(co2);
+ return 0;
+ }
+
// get_wielded_itemstring(self)
static int l_get_wielded_itemstring(lua_State *L)
{
@@ -1954,6 +1982,8 @@ const luaL_reg ObjectRef::methods[] = {
method(ObjectRef, getpos),
method(ObjectRef, setpos),
method(ObjectRef, moveto),
+ method(ObjectRef, punch),
+ method(ObjectRef, right_click),
method(ObjectRef, get_wielded_itemstring),
method(ObjectRef, get_wielded_item),
method(ObjectRef, damage_wielded_item),