aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorRealBadAngel <mk@realbadangel.pl>2013-07-19 19:50:33 +0200
committerRealBadAngel <mk@realbadangel.pl>2013-07-20 20:34:11 +0200
commitd19c8b815dc137ea4c19e5f5a54c40693059b455 (patch)
treed52a03f8357a0c76c2c8df259572e089cf5852c7 /src/script
parentab145c8827504b2b3c897c46e9e7df32cf6324a4 (diff)
downloadminetest-d19c8b815dc137ea4c19e5f5a54c40693059b455.tar.gz
minetest-d19c8b815dc137ea4c19e5f5a54c40693059b455.tar.bz2
minetest-d19c8b815dc137ea4c19e5f5a54c40693059b455.zip
Add set_breath and get_breath to lua API.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_object.cpp29
-rw-r--r--src/script/lua_api/l_object.h6
2 files changed, 35 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index f90b59285..ee24789c5 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -702,6 +702,33 @@ int ObjectRef::l_set_look_yaw(lua_State *L)
return 1;
}
+// set_breath(self, breath)
+int ObjectRef::l_set_breath(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ PlayerSAO* co = getplayersao(ref);
+ if(co == NULL) return 0;
+ u16 breath = luaL_checknumber(L, 2);
+ // Do it
+ co->setBreath(breath);
+ co->m_breath_not_sent = true;
+ return 0;
+}
+
+// get_breath(self)
+int ObjectRef::l_get_breath(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ PlayerSAO* co = getplayersao(ref);
+ if(co == NULL) return 0;
+ // Do it
+ u16 breath = co->getBreath();
+ lua_pushinteger (L, breath);
+ return 1;
+}
+
// set_inventory_formspec(self, formspec)
int ObjectRef::l_set_inventory_formspec(lua_State *L)
{
@@ -1098,6 +1125,8 @@ const luaL_reg ObjectRef::methods[] = {
luamethod(ObjectRef, get_look_yaw),
luamethod(ObjectRef, set_look_yaw),
luamethod(ObjectRef, set_look_pitch),
+ luamethod(ObjectRef, get_breath),
+ luamethod(ObjectRef, set_breath),
luamethod(ObjectRef, set_inventory_formspec),
luamethod(ObjectRef, get_inventory_formspec),
luamethod(ObjectRef, get_player_control),
diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h
index 57dac0e64..a82638442 100644
--- a/src/script/lua_api/l_object.h
+++ b/src/script/lua_api/l_object.h
@@ -179,6 +179,12 @@ private:
// set_look_yaw(self, radians)
static int l_set_look_yaw(lua_State *L);
+ // set_breath(self, breath)
+ static int l_set_breath(lua_State *L);
+
+ // get_breath(self, breath)
+ static int l_get_breath(lua_State *L);
+
// set_inventory_formspec(self, formspec)
static int l_set_inventory_formspec(lua_State *L);