Author |
Message |
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Timer
Alright, i can't seem to get this no matter what i do. I want to create a timer in a script that lasts for a certain amount of time. Basically, i want an effect that lasts for a certain amount of time then goes away. I've tried a couple things with daman's help, but havent been able to get it to work. Any help? Thanks
|
Sat May 23, 2009 4:18 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Timer
Have a timer set the Lifetime to 2?
|
Sat May 23, 2009 4:47 am |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Timer
mail2345 wrote: Have a timer set the Lifetime to 2? So put timer.lifetime = 2?
|
Sat May 23, 2009 5:04 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Timer
Timers don't have lifetime holy ♥♥♥♥.
You can't destroy a timer to the best of my knowledge (admittedly lacking) but you can just ignore it if it's past a certain time. The CPU load from a single timer is going to be virtually nil.
|
Sat May 23, 2009 6:11 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Timer
No, set the effect's lifetime to 2.
You don't need to destroy the timer.
|
Sat May 23, 2009 7:04 am |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
Re: Timer
Why has everybody decided that 2 is the magic number? The Lifetime is how many frames until the object should be removed. If you set it to 2, it's likely to cause a delay. Setting it to 1 is effectively saying "remove next frame".
|
Sat May 23, 2009 7:42 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Timer
I thought that there was a glitch where lifetime = 1 didn't kill the particle.
That might not be this build.
|
Sat May 23, 2009 8:09 am |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: Timer
Code: function Create(self) self.sometimer = Timer() end
function Update(self) if self.sometimer:IsPastSimMS(ANUMBERHERETHATYOUWANTTOUSE) then ♥♥♥♥ TO DO HERE, PROBABLY MovableMan:RemoveMO(self) OR self:GibThis() end end
function Destroy(self) end what is hard about this?
|
Sat May 23, 2009 9:34 am |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Timer
mail2345 wrote: I thought that there was a glitch where lifetime = 1 didn't kill the particle.
That might not be this build. I'm kinda being paranoid here and I always try to set my particles to 2.
|
Sat May 23, 2009 10:32 am |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
Re: Timer
Lifetime = 0 won't kill the particle, as the game sees it as no Lifetime. Setting it to 1 is the way to go, usually.
|
Sat May 23, 2009 7:14 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Timer
Lifetime = 0 is purposefully infinite lifetime.
Look in ancient .inis, the ones where there's comments rather than variable names.
|
Sun May 24, 2009 3:26 am |
|
|
Mind
Joined: Thu Mar 06, 2008 10:54 pm Posts: 1360 Location: USA
|
Re: Timer
Geti wrote: Code: function Create(self) self.sometimer = Timer() end
function Update(self) if self.sometimer:IsPastSimMS(ANUMBERHERETHATYOUWANTTOUSE) then crap TO DO HERE, PROBABLY MovableMan:RemoveMO(self) OR self:GibThis() end end
function Destroy(self) end what is hard about this? Wow, thanks geti. The only thing i didnt have that you have is the destroy self function...thats why it didn't work. Appreciate it!
|
Sun May 24, 2009 9:32 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Timer
What?
function destroy self end
will do ABSOLUTELY NOTHING. It's empty! Useless! Entirely unecessary and actually bad syntax. Guaranteed that wasn't your problem.
|
Mon May 25, 2009 6:12 am |
|
|
Lord Tim
Joined: Fri Apr 27, 2007 4:55 pm Posts: 1178 Location: America!
|
Re: Timer
I haven't tried, but leaving out the Destory(self) could infact break it. These aren't real lua scripts. They're parsed by Data's C++ code, and the functions are added to the C++ objects. If it doesn't find one of the functions that it is expecting, that could break it.
|
Mon May 25, 2009 7:29 am |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
Re: Timer
It will just use the default function.
I would leave it out.
|
Mon May 25, 2009 8:21 am |
|
|
|