View unanswered posts | View active topics It is currently Tue Aug 21, 2018 4:21 pm



Reply to topic  [ 4 posts ] 
 Animating via lua 
Author Message
User avatar

Joined: Thu Jun 21, 2012 3:38 pm
Posts: 122
Location: On a little island called Puerto Rico
Reply with quote
Post Animating via lua
I can understand and read lua and do some basic stuff. I know I can animate sprites via lua. My plan was to use a bunch of checks to see at what time the timer was at and set it to a next frame. Once it hits the end time the timer would reset.

I was wondering if there was a much more efficient way of doing this. Like just have it move frame by frame. Is there a way of doing such a thing?

For what would I need this?

Well from my experience most of the attachables and drop ship parts don't animate with the ini animation mode thing. Only the main part of the actor does. So I'd like to animate these parts, unless I'm doing something wrong of course.

Edit... Oops I think I posted this in the wrong area, sorry :-(


Mon Jan 04, 2016 3:56 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 10108
Location: Here
Reply with quote
Post Re: Animating via lua
For basic animating, there's an ini code way of doing it, but doesn't work on items that force an animation (limbs, guns). I have no idea if it works for armor attachables, but can't hurt to try.

In Base.rte/Actors/Brains/Brains.ini you can see a working example, in the Brain actor code:
Code:
   SpriteFile = ContentFile
      FilePath = Base.rte/Actors/Brains/BrainCaseA.bmp
   FrameCount = 4
   SpriteAnimMode = 2
   SpriteAnimDuration = 500
   SpriteOffset = Vector
      X = -7
      Y = -7

SpriteAnimMode and SpriteAnimDuration are the points of interest.

SpriteAnimDuration is how long (in MS) one animation cycle takes.

SpriteAnimMode determines how the animation works, details below:
Wiki page wrote:
SpriteAnimMode
0 = NOANIM
1 = ALWAYSLOOP
2 = ALWAYSRANDOM
3 = ALWAYSPINGPONG
4 = LOOPWHENMOVING
5 = LOOPWHENOPENCLOSE
6 = PINGPONGOPENCLOSE


If that doesn't work on attachables, you've got the right idea with Lua.


Mon Jan 04, 2016 4:41 am
Profile
User avatar

Joined: Thu Jun 21, 2012 3:38 pm
Posts: 122
Location: On a little island called Puerto Rico
Reply with quote
Post Re: Animating via lua
Thanks for the reply and yes I have been playing around with animation modes and only the main body part of the actor works but I guess it would't hurt to double check for bugs on my part.

If it doesn't work, I'll create the script and post it here if anyone else wants to use it. I just hope it's as easy as it sounds in my head :smile:


Tue Jan 05, 2016 5:01 pm
Profile
User avatar

Joined: Thu Jun 21, 2012 3:38 pm
Posts: 122
Location: On a little island called Puerto Rico
Reply with quote
Post Re: Animating via lua
Code:
function Create(self)
   self.Timer = Timer();
   self.Frame = 1
end

function Update(self)
   if self.Timer:IsPastSimMS(1) then --Sets frame at default starting frame 000.
      self.Frame = 1
   end
   if self.Timer:IsPastSimMS(1000) then --Condition for first frame Change.
      self.Frame = 2
   end
   if self.Timer:IsPastSimMS(2000) then --Condition for Second frame Change.
      self.Frame = 3
      self.Timer = Timer(); --resets the timer.
   end
end


Edit - Welp that's the script I came up with. Pretty simple to be honest.


Tue Jan 05, 2016 7:55 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Google [Bot]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.016s | 16 Queries | GZIP : Off ]