How to use getTime(); properly?

Non-platform specific questions.

How to use getTime(); properly?

Postby Zehper48 » Mon Jun 01, 2009 3:03 pm

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!
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Re: How to use getTime(); properly?

Postby Kalladdolf » Mon Jun 01, 2009 3:13 pm

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 seconds


That'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;}
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: How to use getTime(); properly?

Postby Zehper48 » Mon Jun 01, 2009 3:19 pm

Thanks so much, great start for me, i may have problems later though =p

thanks for replying so fast
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron