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???
The player character still exists, even if they are invisible, so you can use player.PreviousRoom.
player.PreviousRoom only returns the previous room's number; you probably want to use
if (keycode==403) player.ChangeRoom(player.PreviousRoom);
rtfm...
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?
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.
Respect+ Ashen! Very informative...
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?
You could try:
if ((keycode == 380) && (player.Room > 1)) player.ChangeRoom(player.Room - 1);