[I6] Initial property (when used for rooms)

I was surprised to discover in Appendix A2 of the DM4 a note about the initial property:

For rooms Printed or run when the room is arrived in, either by ordinary movement or by PlayerTo.

I gave this a quick test, but I noticed that whatever is in initial is presented every time the room in question is entered, as opposed to only the first time (as might be naively expected as a parallel to its function for non-room objects).

Looking at the Standard Library (6.12.4), the behavior is regulated by a routine called NoteArrival():

[ NoteArrival descin;
    if (location == thedark) { lastdesc = thedark; return; }
    if (location ~= lastdesc) {
        if (location.initial ~= 0) PrintOrRun(location, initial);
        descin = location;
        NewRoom();
        lastdesc = descin;
    }
];

It’s not difficult to change NoteArrival() so that it only prints/runs the contents of a room on the first visit:

[ NoteArrival descin;
    if (location == thedark) { lastdesc = thedark; return; }
    if (location ~= lastdesc) {
        if (location.initial ~= nothing && location hasnt visited) PrintOrRun(location, initial); ! THIS LINE MODIFIED
        descin = location;
        NewRoom();
        lastdesc = descin;
    }
];

DM4 doesn’t have a single example of an initial property for a room object in any example code. (I just checked.) The phrase “initial for a room” is mentioned fleetingly in the table of contents summary for section 21; in that section the relevant discussion seems to be limited to rule 4a in the Standard Library’s rules for what’s printed upon a change of location for the player object (pages 154-155, https://inform-fiction.org/manual/html/s21.html). I’m not sure how many people even know that this is a feature.

There might be too high of a risk of backwards compatibility issues to consider a change in the Standard Library, even though making this change would create some conceptual consistency to the function of initial across both “new” objects (~moved) and “new” rooms (~visited). And it would simplify the beginner author’s task of trying to make the first arrival in a room a little special to the player (which I think I’ve seen several posts about in the past, though probably some were for I7).

For the latter reason, I thought it would be worth posting the idea here for posterity.

On a related note, another fun fact: The inside_description property also has a special function for rooms – it is printed or run after the normal description property, so it looks like a coda to the room description. Interestingly, this happens even if in “superbrief” mode.

When I was writing games in I6, I used initial heavily in its current meaning.

I note that with the current meaning, it’s easy to write code that only runs the first time you visit a room. (Write an initial routine that checks visited.) If you change its meaning to that, it would become difficult to write code that runs every time the room is entered.

Good point!

Do what zarf said. This gives you the flexibility of doing something the first time you enter a room or every time you enter a room and different rooms can be treated differently.

The current arrangement allows you to have different text shown on entering the room and on look, which can be useful.