Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: vrazumijin on Fri 24/04/2020 05:59:24

Title: I cant make my timers work
Post by: vrazumijin on Fri 24/04/2020 05:59:24
Hello

Im trying to make my character change room after entering for the first time, seen a text displayed and wait for, lets say 4 seconds. I do it like this

Code (ags) Select

// room script file

function room_FirstLoad()
{
Overlay.CreateTextual(20,133,0, Game.SpeechFont, 15,"El 28 de julio de 1914,despues de siglos de tensiones, estalla una gran guerra en Europa."); 
SetTimer(1,160);
if (IsTimerExpired(1)) {
player.ChangeRoom(2);
}

}





It builts, but just never changes to room 2.

I cant see what I'm doing wrong, could someone help please?
Title: Re: I cant make my timers work
Post by: Privateer Puddin' on Fri 24/04/2020 06:15:13
It needs to be set in repeatedly execute. Currently, you're setting the timer to 160 loops, but then checking whether it's expired immediately after.
Title: Re: I cant make my timers work
Post by: vrazumijin on Fri 24/04/2020 06:29:18
thanks

and how can I set the timer check in a repeatedly execute mode?
Title: Re: I cant make my timers work
Post by: Privateer Puddin' on Fri 24/04/2020 06:38:38
In the room editor, set a 'Repeatedly execute' event (this should add a function room_RepExec() bit to your room script, where you can add the IsTimerExpired)
Title: Re: I cant make my timers work
Post by: vrazumijin on Fri 24/04/2020 06:42:26
ok, now I get it

thank you so much