diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 16:19:52 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 16:19:52 +0200 |
commit | 56f55ab1af941c5a7c7a7aef4217189f9f2d1680 (patch) | |
tree | 6af7ec25507ab666ffd8e5d6d082600fd31353c7 /src/scriptapi.cpp | |
parent | 2445cbbbdca54d40d1c0a069cc360b06bf44d291 (diff) | |
download | minetest-56f55ab1af941c5a7c7a7aef4217189f9f2d1680.tar.gz minetest-56f55ab1af941c5a7c7a7aef4217189f9f2d1680.tar.bz2 minetest-56f55ab1af941c5a7c7a7aef4217189f9f2d1680.zip |
Add ObjectRef:getvelocity(), ObjectRef:setyaw() and ObjectRef:getyaw()
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r-- | src/scriptapi.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 9803470c3..401de8ade 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -1928,6 +1928,18 @@ private: return 0; } + // getvelocity(self) + static int l_getvelocity(lua_State *L) + { + ObjectRef *ref = checkobject(L, 1); + LuaEntitySAO *co = getluaobject(ref); + if(co == NULL) return 0; + // Do it + v3f v = co->getVelocity(); + pushFloatPos(L, v); + return 1; + } + // setacceleration(self, {x=num, y=num, z=num}) static int l_setacceleration(lua_State *L) { @@ -1953,6 +1965,31 @@ private: return 1; } + // setyaw(self, radians) + static int l_setyaw(lua_State *L) + { + ObjectRef *ref = checkobject(L, 1); + LuaEntitySAO *co = getluaobject(ref); + if(co == NULL) return 0; + // pos + float yaw = luaL_checknumber(L, 2) * core::RADTODEG; + // Do it + co->setYaw(yaw); + return 0; + } + + // getyaw(self) + static int l_getyaw(lua_State *L) + { + ObjectRef *ref = checkobject(L, 1); + LuaEntitySAO *co = getluaobject(ref); + if(co == NULL) return 0; + // Do it + float yaw = co->getYaw() * core::DEGTORAD; + lua_pushnumber(L, yaw); + return 1; + } + // settexturemod(self, mod) static int l_settexturemod(lua_State *L) { @@ -2209,8 +2246,11 @@ const luaL_reg ObjectRef::methods[] = { method(ObjectRef, get_hp), // LuaEntitySAO-only method(ObjectRef, setvelocity), + method(ObjectRef, getvelocity), method(ObjectRef, setacceleration), method(ObjectRef, getacceleration), + method(ObjectRef, setyaw), + method(ObjectRef, getyaw), method(ObjectRef, settexturemod), method(ObjectRef, setsprite), method(ObjectRef, get_entity_name), |