aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorsapier <sapier@users.noreply.github.com>2017-09-01 11:15:12 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-09-01 11:15:12 +0200
commitbf403b923ab4a1e11447b3f81d54d5d0c1124f65 (patch)
tree8c8f73e07051d8de8d5eb5c488bfdbc4377de3b3 /src/script
parentb8f06ad37e142004335e8c2ffaec5fe73b620196 (diff)
downloadminetest-bf403b923ab4a1e11447b3f81d54d5d0c1124f65.tar.gz
minetest-bf403b923ab4a1e11447b3f81d54d5d0c1124f65.tar.bz2
minetest-bf403b923ab4a1e11447b3f81d54d5d0c1124f65.zip
Fix animation frame_speed and blend loosing precision due to incorrec… (#6357)
* Fix animation frame_speed and blend loosing precision due to incorrect data type Add lua function set_animation_frame_speed to update the frame speed without resetting the animation to start
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_object.cpp21
-rw-r--r--src/script/lua_api/l_object.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 24fdeca4b..9b312b3ee 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -604,6 +604,26 @@ int ObjectRef::l_get_eye_offset(lua_State *L)
return 2;
}
+// set_animation_frame_speed(self, frame_speed)
+int ObjectRef::l_set_animation_frame_speed(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ ObjectRef *ref = checkobject(L, 1);
+ ServerActiveObject *co = getobject(ref);
+ if (co == NULL)
+ return 0;
+
+ // Do it
+ if (!lua_isnil(L, 2)) {
+ float frame_speed = lua_tonumber(L, 2);
+ co->setAnimationSpeed(frame_speed);
+ lua_pushboolean(L, true);
+ } else {
+ lua_pushboolean(L, false);
+ }
+ return 1;
+}
+
// set_bone_position(self, std::string bone, v3f position, v3f rotation)
int ObjectRef::l_set_bone_position(lua_State *L)
{
@@ -1937,6 +1957,7 @@ const luaL_Reg ObjectRef::methods[] = {
luamethod(ObjectRef, get_armor_groups),
luamethod(ObjectRef, set_animation),
luamethod(ObjectRef, get_animation),
+ luamethod(ObjectRef, set_animation_frame_speed),
luamethod(ObjectRef, set_bone_position),
luamethod(ObjectRef, get_bone_position),
luamethod(ObjectRef, set_attach),
diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h
index 19cc890c7..2a76d8a70 100644
--- a/src/script/lua_api/l_object.h
+++ b/src/script/lua_api/l_object.h
@@ -126,6 +126,9 @@ private:
// set_animation(self, frame_range, frame_speed, frame_blend, frame_loop)
static int l_set_animation(lua_State *L);
+ // set_animation_frame_speed(self, frame_speed)
+ static int l_set_animation_frame_speed(lua_State *L);
+
// get_animation(self)
static int l_get_animation(lua_State *L);