diff options
author | RealBadAngel <mk@realbadangel.pl> | 2013-03-17 12:16:57 +0100 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2013-03-17 11:39:35 -0400 |
commit | 7f51b2da28e004b82fc6835e5257e619da4666b2 (patch) | |
tree | 929ea44441822f0883fe9f5bd7521a465d128b7b /src/scriptapi_object.cpp | |
parent | c00c8832c6c8cf9a0089a486d026d829e82741a9 (diff) | |
download | minetest-7f51b2da28e004b82fc6835e5257e619da4666b2.tar.gz minetest-7f51b2da28e004b82fc6835e5257e619da4666b2.tar.bz2 minetest-7f51b2da28e004b82fc6835e5257e619da4666b2.zip |
lua methods set_look_pitch and set_look_yaw
Diffstat (limited to 'src/scriptapi_object.cpp')
-rw-r--r-- | src/scriptapi_object.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/scriptapi_object.cpp b/src/scriptapi_object.cpp index ba72840c0..a0f93cbba 100644 --- a/src/scriptapi_object.cpp +++ b/src/scriptapi_object.cpp @@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "scriptapi_entity.h" #include "scriptapi_common.h" - /* ObjectRef */ @@ -582,6 +581,30 @@ int ObjectRef::l_get_look_yaw(lua_State *L) return 1; } +// set_look_pitch(self, radians) +int ObjectRef::l_set_look_pitch(lua_State *L) +{ + ObjectRef *ref = checkobject(L, 1); + PlayerSAO* co = getplayersao(ref); + if(co == NULL) return 0; + float pitch = luaL_checknumber(L, 2) * core::RADTODEG; + // Do it + co->setPitch(pitch); + return 1; +} + +// set_look_yaw(self, radians) +int ObjectRef::l_set_look_yaw(lua_State *L) +{ + ObjectRef *ref = checkobject(L, 1); + PlayerSAO* co = getplayersao(ref); + if(co == NULL) return 0; + float yaw = luaL_checknumber(L, 2) * core::RADTODEG; + // Do it + co->setYaw(yaw); + return 1; +} + // set_inventory_formspec(self, formspec) int ObjectRef::l_set_inventory_formspec(lua_State *L) { @@ -755,6 +778,8 @@ const luaL_reg ObjectRef::methods[] = { luamethod(ObjectRef, get_look_dir), luamethod(ObjectRef, get_look_pitch), luamethod(ObjectRef, get_look_yaw), + luamethod(ObjectRef, set_look_yaw), + luamethod(ObjectRef, set_look_pitch), luamethod(ObjectRef, set_inventory_formspec), luamethod(ObjectRef, get_inventory_formspec), luamethod(ObjectRef, get_player_control), |