Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: on Mon 15/09/2003 20:28:52

Title: Getting system time/date
Post by: on Mon 15/09/2003 20:28:52
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"?
Title: Re:Getting system time/date
Post by: Scorpiorus on Mon 15/09/2003 20:41:41
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
Title: Re:Getting system time/date
Post by: on Wed 17/09/2003 19:15:28
thanks! you actually earned your place in the credits right now ;)
Title: Re:Getting system time/date
Post by: Ishmael on Wed 17/09/2003 20:13:50
offtopic - Scorpiorus has earned his place in many credits, I believe :P
Title: Re:Getting system time/date
Post by: Scorpiorus on Wed 17/09/2003 21:32:10
Thanks Ghost. I very appreciate this, though I don't think it's something, I surely earn(deserve) a place in credits for. ;)

~Cheers
Title: Re:Getting system time/date
Post by: on Thu 18/09/2003 18:54:42
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