How to use getTime(); properly?
Posted:
Mon Jun 01, 2009 3:03 pm
by Zehper48
Hi, I was wondering how to use the getTime(); fucntion.
I want to make a game that "does stuff while your away" so like if you close the game then in if you open it again and 2 hours have passed then somthing happens.
Thanks if you can help!
Re: How to use getTime(); properly?
Posted:
Mon Jun 01, 2009 3:13 pm
by Kalladdolf
stTime getTime();
The stTime is a struct with following members:
sec: Seconds after minute (0 - 59)
min: Minutes after hour (0 - 59)
hour: Hours since midnight (0 - 23)
mday: Day of month (1 - 31)
mon: Month (1 - 12; January = 1)
year: Year (current year)
wday: Day of week (0 - 6; Sunday = 0)
yday: Day of year (0 - 365)
sec_utc: Number of seconds elapsed since midnight (00:00:00), January 1, 1970 (coordinated universal time)
Script Editor Syntax:
stTime t = getTime();
textNumber = t.sec; //to show the secondsThat's what the GE documentation says.
Now, as for your 2 hour issue: When you close the game:
- Code: Select all
stTime t = getTime(hour);
Then save "t" somewhere.
When you open it again:
- Code: Select all
stTime s = getTime(hour);
if(s >= t + 2)//if current time "s" is more or equals your last time "t"
{/do stuff;}
Re: How to use getTime(); properly?
Posted:
Mon Jun 01, 2009 3:19 pm
by Zehper48
Thanks so much, great start for me, i may have problems later though =p
thanks for replying so fast