Getting system time/date

Started by , Mon 15/09/2003 20:28:52

Previous topic - Next topic

Ghost

possibly a very newbie question, sorry.  can i get the system's time and date from within a game so that i can (as done in the first dungeon keeper) display things like : "Happy Birthday to Elke" on her birthday, as some sort of nice little "hidden credit"?

Scorpiorus

Sure, there is the GetTime() function comes to help:

GetTime (int whichvalue)

This function returns various values, representing the current system time. You could use this for timing a loop, or for effects like telling the player to go to bed, and so on.
The WHICHVALUE parameter controls what is returned:

1  current hour (0-23)7
2  current minute (0-59)
3  current second (0-59)
4  current day (1-31)
5  current month (1-12)


Example:

// main global script


function repeatedly_execute() {

int hour = GetTime(1);
int minute = GetTime(2);
int second = GetTime(3);
int day = GetTime(4);
int month = GetTime(5);

//use month and day:

if (month == <number> && day == <birthday>) {
 Display("happy birthday!");
// etc...
}


}


~Cheers

Ghost

thanks! you actually earned your place in the credits right now ;)

Ishmael

offtopic - Scorpiorus has earned his place in many credits, I believe :P
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Scorpiorus

#4
Thanks Ghost. I very appreciate this, though I don't think it's something, I surely earn(deserve) a place in credits for. ;)

~Cheers

Ghost

#5
aaw, but why not putting everyone in the credits who gave a hint? Daemons In The Attics is my first game, and I think there's still a lot for me to learn. It's always nice to have a faithful community- and AGS, together with DIV, has the best one I've met so far  ;D

SMF spam blocked by CleanTalk