Can anyone tell me how do put a time function in my game. Here is the idea I want to be waiting/walking around in a room for about ten seconds or so and I want it to change to night, and the whole background changes not just the sky. Is there a time related background change script? :-\
Look up, in the help file:
SetTimer & SetBackgroundFrame
You'll want to set up the background animation for the two different images.
Scripting:
// After fadein
// Set the timer for 400 ticks (about 10 seconds)
SetBackgroundFrame(1); // to avoid the background flickering between the two
SetTimer(1,400); // 10 seconds
// in the room's repeatedly execute
if (IsTimerExpired(1)==1) {
SetBackgroundFrame(2); // the night time background
}
That should be what you need.
~ d
DISCLAIMER: I'm not a scripting expert
thanks for the tick tip that realy helps :D
How would i go about adding a days of the week thing to this after every cycle, and add people in a different room, or change things in a different room, or have some things different on a special 8th day of the week. ;D
And how would i make people move across the screan like out of one door and into another, when the day changes or like in the middle of the day :) Sorry for all the questions but you people are just so nice ;)
Or mabye ill just ask one at a time later... ???
First, build up a timer like that:
//in the global script
int day=1; // current day
int hour=1; // current hour
int minute=1; // current minute
int loop=1; // current loop
// the next intervals affect the time duration:
int minute_time = 40; // [in game loops]
int hour_time = 60; // [in minutes]
int day_time = 24; // [in hours]
function repeatedly_execute() {
// put anything you want to happen every game cycle here
Ã, Ã, Ã, if (loop > minute_time) { // if loop timer has expired
Ã, Ã, Ã, Ã, Ã, Ã, loop = 1;
Ã, Ã, Ã, Ã, Ã, Ã, minute++;
Ã, Ã, Ã, Ã, Ã, Ã, if (minute > hour_time) { // if minute timer has expired
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, minute = 1;
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, hour++;
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, if (hour > day_time) { // if hour timer has expired
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, hour = 1;
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, day++;
Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, } else loop++; // else increase loop timer
}
// at the end of the global script
export day, hour, minute;
// in the script header
import int day, hour, minute;
From now, to move a character MAN in a current room but only if say it's 8 o'clock on day 3 you can type-in:
in room repeatedly interaction (run-script):
if ((day==3) && (hour==8)) {
MoveCharacterBlocking(MAN, 100, 100, 1);
}
~Cheers
Quote from: Scorpiorus on Wed 25/02/2004 20:50:07
From now, to move a character MAN in a current room but only if say it's 8 o'clock on day 3 you can type-in:
in room repeatedly interaction (run-script):
if ((day==3) && (hour==8)) {
MoveCharacterBlocking(MAN, 100, 100, 1);
}
~Cheers
???
Does this mean its going to make it a lot more tricky to have keyboard movement?
will i have to write that for every direction.
I mean my game wont work now.
:-\
Atleast I cant move around, ill figure something out. THanks for all the help.
Oh, yeah it's a blocking command. For none blocking you can do:
if ((day==3) && (hour==8)) {
if (character[MAN].walking==0) MoveCharacter(MAN, 100, 100);
}