inform7

Inform7: Change a room's description depending on where the player came from


I'm pretty new to Inform and it seems like this shouldn't be too hard to do but I haven't yet found a way. I want to change a room's description based on where the player came from. Something along the lines of:

The Town Square is a room. "As you enter the small town square, [if yourself came from West]
  the rising sun makes silhouettes of the roofs and spires to the East.[otherwise]your long
  shadow strides before you as the Sun rises behind.[end if]"

What's the best way to go about this?


Solution

  • I found a reasonable solution:

    The last location is a room that varies.
    Orientation is a direction that varies.
    
    Before going to anywhere, now the last location is the location of the player.
    After going to anywhere:
        now orientation is the best route from the last location to the location, using even locked doors;
        continue the action.
    
    The Town Square is a room. "As you enter the small town square, [if orientation is east]
    the rising Sun makes silhouettes of the roofs and spires to the East.[otherwise if orientation is west]
    your long shadow strides before you as the Sun rises behind.[end if]"
    

    The "using even locked doors" modifier ensures this will work even if a door closes and locks behind the player. The solution does assume that the player has come via a reversible route, which may not always be the case e.g. if the player has teleported.