aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api')
-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);