A command to return the player to the previous room?

Hi, folks! I tried searching for an answer to this question here and in the documentation, but couldn’t find anything specifically referring to this sort of situation. I really hope I’m not asking something that’s been covered many times before.

Is there a way to implement a command (for example, “back”) that would return the player to the room they were previously in? For example, if the player goes northeast and then wants to go back, rather than making them go southwest, they could just type “back” and the game would interpret it as the player going southwest?

Thanks in advance! :slight_smile:

Hm, off the top of my head, I’d probably have a “last room visited” variable, which I’d change every time the player leaves a room.

Oh, and in double-checking my example code, I found that example #102, “Polarity” seems to do what you’re looking for.

I do wish more games supported this command!

Ah, thanks so much! I must have been looking for the wrong thing in the documentation.

This is definitely a feature that should be implemented in more games. The one I’m working on has a centralized hub with several rooms leading off of it, so this will save the player quite a bit of trouble. :laughing: