View unanswered posts | View active topics It is currently Fri Dec 27, 2024 7:31 am



Reply to topic  [ 3 posts ] 
 Timer == ## 
Author Message
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: Timer == ##
There may be a better way of doing this, but my suggestion is the following:
Code:
function Create(self)
   self.MyTimer = Timer()
end

function Update(self)
   if self.MyTimer and self.MyTimer:IsPastSimMS(1234) then
      self.MyTimer = nil   -- delete the timer
      -- do stuff here
   end
end

A nil value always evaluate to false, so the "do stuff" code will only be accessed once.


Sat Jun 11, 2011 1:06 pm
Profile
User avatar

Joined: Sat Feb 26, 2011 10:29 am
Posts: 163
Reply with quote
Post Re: Timer == ##
Method 1:
Quote:
SetSimTimeLimitMS
Sets the sim time limit value of this Timer, RELATVE to the start time. This is when the timer is supposed to show that it has 'expired' or reached whatever time limit it is supposed to keep track of.
LeftTillSimTimeLimitMS
Returns how much time in ms that there is left till this Timer reaches a certain time limit previously set by SetSimTimeLimitMS.

however, I donno how to use these function.

Method 2:
If timer:IsPastSimMS(N) and not timer:IsPastSimMS(N+1) then

Method 3:
Code:
local functiondone = 0
If IsPastSimMS(N) and functiondone == 0 then
blahblahblah
functiondone = 1;
end


I haven't validated these yet.

Edit:Abdul Alhazred's is much better.


Sat Jun 11, 2011 1:14 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Timer == ##
Code:
function Create(self)
   self.randomTimer = Timer();
end

function Update(self)
   if self.ticked == nil and self.randomTimer:IsPastSimMS(1337) then
      self.ticked = true;

      (stuff)

   end
end


Sat Jun 11, 2011 8:51 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

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