Return to last room [SOLVED]

Started by Candle, Fri 22/07/2005 23:17:39

Previous topic - Next topic

Candle

Going to have a PDA in my game and on it will be a button to click when they are done with the PDA it will take them to the last room/place they were at when they click the PDA .
Any code to take them back to where they came from ?

Scummbuddy

PreviousRoom property
(Formerly known as character[].prevroom, which is now obsolete)

readonly int Character.PreviousRoom

Gets the room number that the character was previously in. If the character is still in the room that they started in, this will be -1. Otherwise, it will be the room number of the room that they were last in.
This is a read-only property. It is set automatically by ChangeRoom.

Example:

Display("EGO's previous room was %d.", character[EGO].PreviousRoom);

will display the EGO character's previous room.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Candle

#2
I can't seem to find that  PreviousRoom property in my help file ? I'm using  2.63 beta .
Ok I found it but don't understand it ?

strazer

Surely you know how to change rooms (Character.ChangeRoom / NewRoom) and now you know the number of the room the character was in previously in (Character.PreviousRoom / character[].prevroom), so just do
  player.ChangeRoom(player.PreviousRoom);

Candle

Well I gave that a try and got this error ?
Code: ags
player.ChangeRoom(player.PreviousRoom);

Code: ags
---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:

In: 'Room script'

Error (line 6): 'PreviousRoom' is not a member of 'GameCharacter'

Do you want to fix the script now? (Your room has not been saved).



I'm using it in a hotspot with a click on hotspot.

strazer

QuoteI'm using  2.63 beta .

I guess the Character.PreviousRoom property is only available since the final AGS v2.7.
Try player.prevroom then. Why are you using this old beta anyway?

Candle

Quote from: strazer on Sat 23/07/2005 03:15:11
QuoteI'm using 2.63 beta .

I guess the Character.PreviousRoom property is only available since the final AGS v2.7.
Try player.prevroom then. Why are you using this old beta anyway?
I started my gamne with it and don't want to start over .
I'm not sure about the code for Character.PreviousRoom guess you will have to spell it out for me as they say . lol

Candle

Thats ok . I will do it some other way .

Ubel

Quote from: Candle on Sat 23/07/2005 03:21:37
I started my gamne with it and don't want to start over .

You don't have to start over, you can import your game into a newer version. Just remember to backup the game before doing it. In case you get any problems with it.

And by the way, I think "character[GetPlayerCharacter].prevroom" should work with that version.

Candle

Thank you strazer I upgraded and that works great and my game still works with the upgrade .  ;D

SMF spam blocked by CleanTalk