Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: tbrucelarson on Sun 10/02/2013 02:01:10

Title: entering a room a second time
Post by: tbrucelarson on Sun 10/02/2013 02:01:10
My intention is to start a cutscene after a dialogue ends. However,the dialogue changes rooms before it ends. I tried using "CallRoomScript" within the dialogue, but nothing happens after the room switch. Possibly because it doesn't work between rooms.
[Dialogue script]
cNichint: Understood.
  if(player.Room == 29)CallRoomScript(1);
  player.ChangeRoom(29, 394, 362);
stop

[room script]
function on_call(int var)
{
  if(var==1){
    Wait(160);
    cRichard.Say("Right. I'll take my leave then.");
    cRichard.Say("Release him Sheriff.");
    cRichard.Walk(799, 575);
    cAbraham.Walk(396, 320);
}
}
Is there a way to activate a function when you enter a second time?
Title: Re: entering a room a second time
Post by: Slasher on Sun 10/02/2013 08:19:03
Your walks should be eBlock as far as I can see else the script will automatically run player change room before you have the walks.

You could make a variable to indicate first, second, third, fouth etc time you enter the same room.

You do have First Load already evented in Room events panel. After that you can use variables.

Hope this helps.

Title: Re: entering a room a second time
Post by: Khris on Sun 10/02/2013 11:09:41
This:
if(player.Room == 29)CallRoomScript(1);

is called before the room change; player.Room is obviously never 29 at that point.
You cannot write this and expect AGS to "remember it" for later; it'll only work if the condition is true at the very nanosecond this line is processed.

You can do this:

Code (ags) Select
// room script
bool second_time;

// in after fadein
  if (second_time) {
    // 2nd entry code
    second_time = false;
  }

// enters first time
  // 1st entry code
  second_time = true;
Title: Re: entering a room a second time
Post by: tbrucelarson on Sun 10/02/2013 20:20:24
That script worked like a charm. Thanks.