View unanswered posts | View active topics It is currently Fri Apr 26, 2024 10:52 am



Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
 Timer 
Author Message
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1359
Location: USA
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Timer
Have a timer set the Lifetime to 2?


Sat May 23, 2009 4:47 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1359
Location: USA
Reply with quote
Post Re: Timer
mail2345 wrote:
Have a timer set the Lifetime to 2?



So put timer.lifetime = 2?


Sat May 23, 2009 5:04 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post 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
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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
Profile WWW
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post 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
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post 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
Profile WWW

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post 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
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1359
Location: USA
Reply with quote
Post 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
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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
Profile
User avatar

Joined: Fri Apr 27, 2007 4:55 pm
Posts: 1178
Location: America!
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Timer
It will just use the default function.

I would leave it out.


Mon May 25, 2009 8:21 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 21 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users


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.095s | 15 Queries | GZIP : Off ]