Usage
returns float value of the time in seconds
parameters none
f = sys.getTime();
Notes
- getTime retuns the time in seconds since map start. It is accurate to four digits of precision.
For cases where you'd like to halt execution of a thread, consider the wait command instead.
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 }