aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_object.cpp
diff options
context:
space:
mode:
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>2015-02-21 23:38:53 +0200
committerest31 <MTest31@outlook.com>2015-06-22 01:53:38 +0200
commit660fa516bfe774c77947c47a97154d6f069f414d (patch)
tree60cbb826cfda9f08bd747aab3f087a75aec1df4c /src/script/lua_api/l_object.cpp
parent622918d8a86ab2bb8a6ef1211b9a2ed1ad4c9b96 (diff)
downloadminetest-660fa516bfe774c77947c47a97154d6f069f414d.tar.gz
minetest-660fa516bfe774c77947c47a97154d6f069f414d.tar.bz2
minetest-660fa516bfe774c77947c47a97154d6f069f414d.zip
Fix some issues with animations, and allow non-looped animations to be defined
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r--src/script/lua_api/l_object.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 48d054dcd..4b1cc39fb 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -449,7 +449,7 @@ int ObjectRef::l_get_physics_override(lua_State *L)
return 1;
}
-// set_animation(self, frame_range, frame_speed, frame_blend)
+// set_animation(self, frame_range, frame_speed, frame_blend, frame_loop)
int ObjectRef::l_set_animation(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
@@ -466,7 +466,10 @@ int ObjectRef::l_set_animation(lua_State *L)
float frame_blend = 0;
if(!lua_isnil(L, 4))
frame_blend = lua_tonumber(L, 4);
- co->setAnimation(frames, frame_speed, frame_blend);
+ bool frame_loop = true;
+ if(lua_isboolean(L, 5))
+ frame_loop = lua_toboolean(L, 5);
+ co->setAnimation(frames, frame_speed, frame_blend, frame_loop);
return 0;
}
@@ -482,12 +485,14 @@ int ObjectRef::l_get_animation(lua_State *L)
v2f frames = v2f(1,1);
float frame_speed = 15;
float frame_blend = 0;
- co->getAnimation(&frames, &frame_speed, &frame_blend);
+ bool frame_loop = true;
+ co->getAnimation(&frames, &frame_speed, &frame_blend, &frame_loop);
push_v2f(L, frames);
lua_pushnumber(L, frame_speed);
lua_pushnumber(L, frame_blend);
- return 3;
+ lua_pushboolean(L, frame_loop);
+ return 4;
}
// set_local_animation(self, {stand/idle}, {walk}, {dig}, {walk+dig}, frame_speed)