aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2014-01-08 13:47:53 +0100
committerBlockMen <nmuelll@web.de>2014-04-12 17:44:15 +0200
commita1db9242ec491efdee70a7184aa61e861b17595a (patch)
tree04bdd2302f8b3c4285ddb8f5ba669f7adc6bf4b9 /src/script
parente149d1ad9a623b9f8ca597839f7b850841c54781 (diff)
downloadminetest-a1db9242ec491efdee70a7184aa61e861b17595a.tar.gz
minetest-a1db9242ec491efdee70a7184aa61e861b17595a.tar.bz2
minetest-a1db9242ec491efdee70a7184aa61e861b17595a.zip
Add third person view
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_object.cpp26
-rw-r--r--src/script/lua_api/l_object.h3
2 files changed, 29 insertions, 0 deletions
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}
};
diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h
index 2c53d1a69..be1068c14 100644
--- a/src/script/lua_api/l_object.h
+++ b/src/script/lua_api/l_object.h
@@ -231,6 +231,9 @@ private:
// override_day_night_ratio(self, type, list)
static int l_override_day_night_ratio(lua_State *L);
+ // set_local_animation(self, {stand/ilde}, {walk}, {dig}, {walk+dig}, frame_speed)
+ static int l_set_local_animation(lua_State *L);
+
public:
ObjectRef(ServerActiveObject *object);