Data Realms Fan Forums
http://forums.datarealms.com/

Timer == ##
http://forums.datarealms.com/viewtopic.php?f=73&t=24208
Page 1 of 1

Author:  Abdul Alhazred [ Sat Jun 11, 2011 1:06 pm ]
Post subject:  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.

Author:  Xery [ Sat Jun 11, 2011 1:14 pm ]
Post subject:  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.

Author:  CaveCricket48 [ Sat Jun 11, 2011 8:51 pm ]
Post subject:  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

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/