diff options
author | MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com> | 2015-02-21 23:38:53 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-06-22 01:53:38 +0200 |
commit | 660fa516bfe774c77947c47a97154d6f069f414d (patch) | |
tree | 60cbb826cfda9f08bd747aab3f087a75aec1df4c /src/script/lua_api | |
parent | 622918d8a86ab2bb8a6ef1211b9a2ed1ad4c9b96 (diff) | |
download | minetest-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')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 13 | ||||
-rw-r--r-- | src/script/lua_api/l_object.h | 2 |
2 files changed, 10 insertions, 5 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) diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h index 02bb06ecc..9e4a62058 100644 --- a/src/script/lua_api/l_object.h +++ b/src/script/lua_api/l_object.h @@ -111,7 +111,7 @@ private: // get_physics_override(self) static int l_get_physics_override(lua_State *L); - // set_animation(self, frame_range, frame_speed, frame_blend) + // set_animation(self, frame_range, frame_speed, frame_blend, frame_loop) static int l_set_animation(lua_State *L); // get_animation(self) |