From a1db9242ec491efdee70a7184aa61e861b17595a Mon Sep 17 00:00:00 2001 From: BlockMen Date: Wed, 8 Jan 2014 13:47:53 +0100 Subject: Add third person view --- src/script/lua_api/l_object.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/script/lua_api/l_object.cpp') diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 90af51cc7..e801ddd5f 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -406,6 +406,31 @@ int ObjectRef::l_set_animation(lua_State *L) return 0; } +// set_local_animation(self, {stand/ilde}, {walk}, {dig}, {walk+dig}, frame_speed) +int ObjectRef::l_set_local_animation(lua_State *L) +{ + //NO_MAP_LOCK_REQUIRED; + ObjectRef *ref = checkobject(L, 1); + Player *player = getplayer(ref); + if (player == NULL) + return 0; + // Do it + v2f frames[4]; + for (int i=0;i<4;i++) { + if(!lua_isnil(L, 2+1)) + frames[i] = read_v2f(L, 2+i); + } + float frame_speed = 30; + if(!lua_isnil(L, 6)) + frame_speed = lua_tonumber(L, 6); + + if (!getServer(L)->setLocalPlayerAnimations(player, frames, frame_speed)) + return 0; + + lua_pushboolean(L, true); + return 0; +} + // set_bone_position(self, std::string bone, v3f position, v3f rotation) int ObjectRef::l_set_bone_position(lua_State *L) { @@ -1270,5 +1295,6 @@ const luaL_reg ObjectRef::methods[] = { luamethod(ObjectRef, hud_set_hotbar_selected_image), luamethod(ObjectRef, set_sky), luamethod(ObjectRef, override_day_night_ratio), + luamethod(ObjectRef, set_local_animation), {0,0} }; -- cgit v1.2.3