Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sayhello-hello on Mon 15/03/2010 13:10:50

Title: Checking what room character is in
Post by: Sayhello-hello on Mon 15/03/2010 13:10:50
Hi,

I'd like to make a function where I can check what room the character is/was in. Basically something happens (anywhere for example room X) and the player is transported to a certain room (Y) once the player exits room Y, he has to be back at room X again. But since it's he might not necessarily be transported to room Y from X, he could have been transported from room Z to Y, then how would I go about doing this.

I was thinking of making a function that somehow checked where the character was before room Y and then call the function in room Y in order to get the character back to the right room.
Title: Re: Checking what room character is in
Post by: NsMn on Mon 15/03/2010 13:17:02

Character.Room
Character.PreviousRoom
Title: Re: Checking what room character is in
Post by: Sayhello-hello on Mon 15/03/2010 13:22:21
Ah! Just that easy huh? :)

Thanks.
Title: Re: Checking what room character is in
Post by: Sayhello-hello on Tue 16/03/2010 16:23:21
Since Character.Room and Character.PreviousRoom are readonlys how would I actually use the data to change rooms (or do whatever)?

Like the character is currently in room X, then he moves into room Y where following message is displayed "Hello". This message will only be displayed if he was in room X before.
Title: Re: Checking what room character is in
Post by: Crimson Wizard on Tue 16/03/2010 16:30:59
Is this a single question or two questions?

QuoteSince Character.Room and Character.PreviousRoom are readonlys how would I actually use the data to change rooms
character.ChangeRoom(Room-Number, X, Y);

QuoteLike the character is currently in room X, then he moves into room Y where following message is displayed "Hello". This message will only be displayed if he was in room X before.

if (character.Room == Y && character.PreviousRoom == X)
{
   DisplayMessage("Hello");
}
Title: Re: Checking what room character is in
Post by: Khris on Tue 16/03/2010 17:11:31
Obviously, the first check is redundant if that code is inside room Y's after fadein event :)