Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: td on Tue 01/08/2006 12:15:27

Title: Previous room for 1 person game.
Post by: td on Tue 01/08/2006 12:15:27
I trying to add
character[EGO].PreviousRoom;
function when some keycode is pressed (403 for example) . But my character is hide (therefore i haven't character) coz i make 1 person game. So the code must be:

if (keycode==403) ....

And then???
Title: Re: Previous room for 1 person game.
Post by: SSH on Tue 01/08/2006 12:18:38
The player character still exists, even if they are invisible, so you can use player.PreviousRoom.
Title: Re: Previous room for 1 person game.
Post by: Khris on Tue 01/08/2006 13:14:45
player.PreviousRoom only returns the previous room's number; you probably want to use
if (keycode==403) player.ChangeRoom(player.PreviousRoom);

rtfm...
Title: Re: Previous room for 1 person game.
Post by: td on Tue 01/08/2006 19:28:46
Thanks Khris. That Is that!

EDIT:
Yes. But in some moments in my game PreviousRoom function must be blocked (player can't back).
How can i blocked this, Khris?
Title: Re: Previous room for 1 person game.
Post by: Ashen on Wed 02/08/2006 11:19:04
You could add an on_key_press function to those rooms, using ClaimEvent() to block the main one:


// Room script
function on_key_press (int keycode) {
  if (keycode == 403) ClaimEvent();
}


Or, you could create a Custom Property (http://www.adventuregamestudio.co.uk/manual/Custom%20Properties.htm) that determines whether or not backtracking is allowed. E.g., create a boolean property called 'AllowBack', and change the Global on_key_press condition to:

if (keycode==403 && GetRoomProperty("AllowBack") == true) player.ChangeRoom(player.PreviousRoom);


If it's just at specific times you want backtracking disabled (e.g. the player enters the room and the door locks behind them - can't go back untill they unlock it), just create a script variable, and have on_key_press check that instead/as well.
Title: Re: Previous room for 1 person game.
Post by: td on Thu 03/08/2006 19:59:42
Respect+ Ashen! Very informative...
Title: Re: Previous room for 1 person game.
Post by: td on Sat 05/08/2006 09:33:24
Line
  if (keycode==380) player.ChangeRoom(player.PreviousRoom);
is work,but here is a problem i meeted:
For example i visited rooms: 1>2>3>4
If i press button (380) i retuned : 4>3>4>3 etc.  I thought it must be 4>3>2>1 and i need right this.

How can i change this?
Title: Re: Previous room for 1 person game.
Post by: monkey0506 on Sat 05/08/2006 13:28:46
You could try:

if ((keycode == 380) && (player.Room > 1)) player.ChangeRoom(player.Room - 1);