Checking what room character is in

Started by Sayhello-hello, Mon 15/03/2010 13:10:50

Previous topic - Next topic

Sayhello-hello

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.

NsMn

Code: ags

Character.Room
Character.PreviousRoom

Sayhello-hello


Sayhello-hello

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.

Crimson Wizard

#4
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");
}

Khris

Obviously, the first check is redundant if that code is inside room Y's after fadein event :)

SMF spam blocked by CleanTalk