Usage

returns float value of the time in seconds

parameters none

f = sys.getTime();

Notes

Example

Here we'll use getTime to power a loop which will heal a creature over time. We will restore 100 health per second to the creature for 5 seconds.

   1 
   2 float fOldTime;
   3 float fCurrentTime;
   4 float fDelta;
   5 float fEndTime;
   6 entity hurtMonster;
   7 
   8 //inital time set up
   9 fCurrentTime = sys.getTime();
  10 fOldTime = fCurrentTime;
  11 fEndTime = fCurrentTime + 5;
  12 
  13 while( fCurrentTime < fEndTime ) {
  14  
  15  fDelta = fCurrentTime - fOldTime;
  16  hurtMonster.setHealth( hurtMonster.getHealth() + 100 * fDelta);
  17 
  18  //advance the counters
  19  fOldTime = fCurrentTime;
  20  fCurrentTime = sys.getTime();
  21 
  22  //mandatory wait frame
  23  sys.waitFrame();
  24 
  25 }

ScriptEvent getTime (last edited 2005-11-01 18:01:03 by JimShepard)