Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: timlump on Sat 27/05/2006 22:16:07

Title: Computer time scripting (SOLVED)
Post by: timlump on Sat 27/05/2006 22:16:07
In my game I plan to have a realtime day/night system but although i know it should be possible how would I make the game run a piece of code say at 5pm.
Please help i have no idea where to begin without this forums brilliant help.
Title: Re: computer time scripting
Post by: Ashen on Sat 27/05/2006 22:32:58
DateTime functions & properties (http://www.adventuregamestudio.co.uk/manual/DateTime%20functions%20and%20properties.htm). (Particularly DateTime.Now and DateTime.Hour)

So something like:

DateTime *dt;

//rep_ex
dt = DateTime.Now;
if (dt.Hour == 17) {
  // Do stuff at 5:00 PM
  // Add dt.Minute and dt.Second checks to make it happen at EXACTLY 5, rather than for the whole hour
}

Title: Re: computer time scripting
Post by: timlump on Sun 28/05/2006 00:39:40
where would i put that exactly
Title: Re: computer time scripting
Post by: Khris on Sun 28/05/2006 02:27:22
You'd put it in the global script.

Insert this at the beginning, outside any function:
DateTime *dt;

The following belongs inside the repeatedly_execute function:
//rep_exÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, <--- INDICATION OF WHERE TO PUT IT BY ASHEN
dt = DateTime.Now;
if (dt.Hour == 17) {
Ã,  // Do stuff at 5:00 PM
Ã,  // Add dt.Minute and dt.Second checks to make it happen at EXACTLY 5, rather than for the whole hour
}

Title: Re: computer time scripting
Post by: timlump on Sun 28/05/2006 09:24:58
i tried your code and it refuse to work but luckily with a little copying and pasteing
i managed to get exactly the scripting effect i wanted.
Now may game features a 24 hour day time /night time effect.
Title: Re: Computer time scripting (SOLVED)
Post by: Khris on Sun 28/05/2006 18:40:16
This sounds like "Your suggestion didn't work, but I got it working on my own by following your instructions." ;)