| Data Realms Fan Forums http://45.55.195.193/  | 
|
| Timer http://45.55.195.193/viewtopic.php?f=73&t=14878  | 
	Page 1 of 2 | 
| Author: | Mind [ Sat May 23, 2009 4:18 am ] | 
| Post subject: | 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  
		
		 | 
	|
| Author: | mail2345 [ Sat May 23, 2009 4:47 am ] | 
| Post subject: | Re: Timer | 
Have a timer set the Lifetime to 2?  | 
	|
| Author: | Mind [ Sat May 23, 2009 5:04 am ] | 
| Post subject: | Re: Timer | 
mail2345 wrote: Have a timer set the Lifetime to 2? So put timer.lifetime = 2?  | 
	|
| Author: | Grif [ Sat May 23, 2009 6:11 am ] | 
| Post subject: | 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.  | 
	|
| Author: | mail2345 [ Sat May 23, 2009 7:04 am ] | 
| Post subject: | Re: Timer | 
No, set the effect's lifetime to 2. You don't need to destroy the timer.  | 
	|
| Author: | TheLastBanana [ Sat May 23, 2009 7:42 am ] | 
| Post subject: | 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".  | 
	|
| Author: | mail2345 [ Sat May 23, 2009 8:09 am ] | 
| Post subject: | Re: Timer | 
I thought that there was a glitch where lifetime = 1 didn't kill the particle. That might not be this build.  | 
	|
| Author: | Geti [ Sat May 23, 2009 9:34 am ] | 
| Post subject: | 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  | 
	|
| Author: | numgun [ Sat May 23, 2009 10:32 am ] | 
| Post subject: | 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.  | 
	|
| Author: | TheLastBanana [ Sat May 23, 2009 7:14 pm ] | 
| Post subject: | 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.  | 
	|
| Author: | Grif [ Sun May 24, 2009 3:26 am ] | 
| Post subject: | Re: Timer | 
Lifetime = 0 is purposefully infinite lifetime. Look in ancient .inis, the ones where there's comments rather than variable names.  | 
	|
| Author: | Mind [ Sun May 24, 2009 9:32 pm ] | 
| Post subject: | 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 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!  
		
		 | 
	|
| Author: | Grif [ Mon May 25, 2009 6:12 am ] | 
| Post subject: | 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.  | 
	|
| Author: | Lord Tim [ Mon May 25, 2009 7:29 am ] | 
| Post subject: | 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.  | 
	|
| Author: | mail2345 [ Mon May 25, 2009 8:21 am ] | 
| Post subject: | Re: Timer | 
It will just use the default function. I would leave it out.  | 
	|
| Page 1 of 2 | All times are UTC [ DST ] | 
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/  | 
|