Scripts / How to loop an animation in Lua?

Author
Message
Jerry Tremble
GameGuru TGC Backer
12
Years of Service
User Offline
Joined: 5th Nov 2012
Location: Sonoran Desert
Posted: 5th Feb 2014 21:26 Edited at: 5th Feb 2014 21:28
Hi! I've been slowly converting old FPSC assets to work in Reloaded. This is my first attempt at an animated object, the ceiling fan from Modern Day 2. I made a Lua script for the animation, and it will animate in the editor. If I launch the game, it won't animate. If I go into 3D edit mode, it will play the animation once, but if I add another fan while in 3D edit mode, it will loop indefinitely, or at least until I go back to the editor mode and relaunch. I've tried numerous times to get a continuous loop, including calling the function immediately after it ends, to no avail. Does anybody have any suggestions? Here is my current lua fanmove script:







Here's a video of what I mean (if it works):





[youtube]http://youtu.be/hxvpG24vHHU[/youtube]
PM
rolfy
18
Years of Service
User Offline
Joined: 23rd Jun 2006
Location:
Posted: 6th Feb 2014 01:56 Edited at: 6th Feb 2014 02:13
I have found that animation loops without LUA scripting, all that was required was anim info in the .fpe. Boned and vertex animations both run, with issues only with vertex anims which tend to be real slow.

I too tried to use scripting to run these without success but it's early days and still trying to get to grips with LUA



I can only assume your script is playing the animation once then ends, perhaps you need to find a way to either loop the script or a function to loop the anim once it's triggered. It will play looped in the editor if: playanimineditor = 1 regardless of any scripting.



I have been testing out some destructible buildings, roads etc and your script will likely be what I am looking for to get a start since I was wanting play and stop, I will try it out later



Still till we get decal,videotextures or at least explosions of some sort and a way to trigger these scripted as well then it's all a long way off.
Jerry Tremble
GameGuru TGC Backer
12
Years of Service
User Offline
Joined: 5th Nov 2012
Location: Sonoran Desert
Posted: 6th Feb 2014 03:13 Edited at: 6th Feb 2014 03:13
LOL, thanks, Rolfy, you were correct! I just deleted my script and now it's animating! That is so funny and kinda aggravating at the same time, as I spent all morning trying to figure it out, trying to loop the function when I didn't actually need the function. I learned something, at least, actually two things, so I guess it was a worthwhile endeavor. Thanks again!
PM

Login to post a reply

Server time is: 2024-12-21 18:58:59
Your offset time is: 2024-12-21 18:58:59