inform7

Inform7: How do I make Inform7 display text only once when you enter a room but display every time you enter that room


I would like to know if you can have Inform7 display something like say "Welcome to the room!". only once when you enter that room. All preceding commands you type will not re-trigger this message but if you leave and re-enter the room it will display again.

The idea is that I have a person in the room who I want to have some greeting text. Also if possible can I make their text print out after anything else that may be printed in the room?


Solution

  • You can record whether an actor has just arrived in a room using a new either/or property ("a new arrival" in this example) - set it in an after rule for the "going" action, and clear it in a general every turn rule. The greeting text can be displayed in another every turn rule - a more specific one to ensure that it runs before the general one that clears the property - restricted to cases where the person saying the greeting ("The Greeter" in this example) is both in the correct room ("The Greeting Room" in this example) and able to see a person who is a new arrival:

    A person can be a new arrival.
    A person is usually not a new arrival.
    
    After going:
        now the actor is a new arrival;
        continue the action.
    
    Every turn when the Greeter is in the Greeting Room and the Greeter can see a new arrival person:
        if the player can see the Greeter:
            say "Welcome to the Greeting Room![line break]".
    
    Every turn:
        repeat with newcomer running through new arrival people:
            now the newcomer is not a new arrival.