Data Realms Fan Forums http://45.55.195.193/ |
|
Yet Another Animation question http://45.55.195.193/viewtopic.php?f=73&t=17948 |
Page 1 of 1 |
Author: | Djinn [ Fri Feb 26, 2010 4:29 am ] |
Post subject: | Yet Another Animation question |
Now, you can check what frame the animation is on with self.Frame == whatever, is there any similarly simple way to SET the frame, or is that impossible currently? Couldn't find anything about it in the wiki |
Author: | TheLastBanana [ Fri Feb 26, 2010 4:36 am ] |
Post subject: | Re: Yet Another Animation question |
self.Frame = 0 Sets self.Frame to 0. If the LuaDocs say it's read-only, then that's a lie. |
Author: | Mind [ Fri Feb 26, 2010 4:36 am ] |
Post subject: | Re: Yet Another Animation question |
Just like u put ^_^ Code: function Update(self) if alskdjas;ldkjad self.Frame = (#); end end unless im missing what you're asking. o-O aw tlb |
Author: | Djinn [ Fri Feb 26, 2010 4:41 am ] |
Post subject: | Re: Yet Another Animation question |
Good lord I put 2 equal signs. If this works I'm going to feel retarded again. |
Author: | Grif [ Fri Feb 26, 2010 6:03 am ] |
Post subject: | Re: Yet Another Animation question |
== checks = sets |
Author: | Djinn [ Fri Feb 26, 2010 6:24 am ] |
Post subject: | Re: Yet Another Animation question |
Yeah okay it works I'm just a retard. Second of all, once I set the frame, how do I get it to re-increment past that frame. Is there a function that will do it or do I have to make my own timer? For reference here's my really basic code: function Create(self) end function Update(self) if self.Frame > 3 then self.Frame = 1 end end |
Author: | TheLastBanana [ Fri Feb 26, 2010 6:32 am ] |
Post subject: | Re: Yet Another Animation question |
Depending on what you're setting the frame of, you may have a problem with the object itself resetting its frame. Store a separate variable for frame (such as self.currentFrame) and work with that like you would normally work with frames. Then, at the end of Update, set self.frame to self.currentFrame. |
Author: | Djinn [ Fri Feb 26, 2010 9:15 pm ] |
Post subject: | Re: Yet Another Animation question |
Here's my current (non-working) code. I'm trying to just have it animate completely by Lua, but I'm evidently doing something wrong. Also, even if this does work, there's no delay in between frames (not implemented yet - is there a better way than using IsPastSimMS() something or other?). The pseudocode for this is something like: - Random choice between 1 and 6 - Depending on number chosen, start the frame at some number and continue to some other number (using a for loop, I assume) - Once that number is achieved and it's below a certain altitude, settle it. Any tips? function Create(self) self.lifetimer = Timer(); self.plantframe = 0; end function Update(self) self.ToSettle = false; local chance = math.random(1,1) if chance == 1 then for i = 1,6 do self.plantframe = self.plantframe + 1; self.frame = self.plantframe; end if self.Frame > 5 then self.ToSettle = true; end end end |
Author: | Grif [ Fri Feb 26, 2010 10:24 pm ] |
Post subject: | Re: Yet Another Animation question |
you could theoretically use self.age % <ms> as a timer, but in practice lua updates too slowly for that to work. basic script that should accomplish what you want: function Create(self) self.frametohit = math.random(1,6); self.currentframe = 0; self.altitude = 10; self.animtimer = Timer(); end function Update(self) if self.animtimer:IsPastSimMS(100) == true then if self.currentframe < self.frametohit then self.currentframe = self.currentframe + 1; elseif self.currentframe == self.frametohit then if self:GetAltitude(0,4) < self.altitude then self.ToSettle = true; end end end self.Frame = self.currentframe; end |
Author: | Djinn [ Fri Feb 26, 2010 11:55 pm ] |
Post subject: | Re: Yet Another Animation question |
Here's the modified version of it which is probably closer to what I'm trying to get done - as it stands, it only goes to the first frame then stops. Augh. Code: function Create(self) self.minframe = 0; self.maxframe = 0; self.lifetimer = Timer(); end function Update(self) self.ToSettle = false; local chance = math.random(1,2) if chance == 1 then self.minframe = 0; self.maxframe = 6; if self.lifetimer:IsPastSimMS(50) == true then if self.minframe < self.maxframe then self.minframe = self.minframe + 1; elseif self.minframe == self.maxframe then if self:GetAltitude(0,4) < 2 then self.ToSettle = true; end end end elseif chance == 2 then self.minframe = 7; self.maxframe = 12; if self.lifetimer:IsPastSimMS(50) == true then if self.minframe < self.maxframe then self.minframe = self.minframe + 1; elseif self.minframe == self.maxframe then if self:GetAltitude(0,4) < 2 then self.ToSettle = true; end end end end self.Frame = self.minframe; end |
Author: | Grif [ Sat Feb 27, 2010 1:11 am ] |
Post subject: | Re: Yet Another Animation question |
because you're setting minframe every update like, think about it if you're running that code every update frame, then you're constantly telling it to set minframe to either 0 or 7; the rest of the code is moot try this: http://lua.pastebin.com/Hbz6kgs7 |
Author: | Djinn [ Sat Feb 27, 2010 5:51 am ] |
Post subject: | Re: Yet Another Animation question |
Grif wrote: because you're setting minframe every update like, think about it if you're running that code every update frame, then you're constantly telling it to set minframe to either 0 or 7; the rest of the code is moot try this: http://lua.pastebin.com/Hbz6kgs7 Bam, that works, I'll keep this aspect of Lua in mind, thank. |
Author: | Djinn [ Sun Feb 28, 2010 6:44 am ] |
Post subject: | Re: Yet Another Animation question |
Hey look more garbage! I'm trying to get it to print frame upon hitting growthframe and it's not doing it and I'm just getting pissed off at it so I'll pray to the Lua pantheon once again for salvation. Code: function Create(self) self.minframe = 0; self.maxframe = 0; self.growthframe = 0; self.lifetimer = Timer(); local chance = math.random(1,8) if chance == 1 then self.minframe = 1; self.maxframe = 6; self.growthframe = 3; elseif chance == 2 then self.minframe = 7; self.maxframe = 12; self.growthframe = 9; elseif chance == 3 then self.minframe = 13; self.maxframe = 18; self.growthframe = 5; elseif chance == 4 then self.minframe = 19; self.maxframe = 23; self.growthframe = 21; elseif chance == 5 then self.minframe = 24; self.maxframe = 29; self.growthframe = 26; elseif chance == 6 then self.minframe = 30; self.maxframe = 35; self.growthframe = 32; elseif chance == 7 then self.minframe = 36 self.maxframe = 41; self.growthframe = 38; elseif chance == 8 then self.minframe = 42; self.maxframe = 47; self.growthframe = 44; end end function Update(self) self.ToSettle = false; if self.lifetimer:IsPastSimMS(150) == true then self.lifetimer:Reset(); if self.minframe < self.maxframe then self.minframe = self.minframe + 1; elseif self.minframe == self.growthframe then print(self.Frame) elseif self.minframe == self.maxframe then if self:GetAltitude(0,4) < 2 then self.ToSettle = true; end end end self.Frame = self.minframe; end |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |