In Inform 6, I got quite used to printing a different room description the first time a room is visited, to provide additional flavour text that is not essential to the game. This works because Inform 6 sets the visited flag only after printing the first look result.
The Dialog standard library seems like it sets the visited flag before trying to look, which also makes sense. Is there a better way to achieve what I want in Dialog?
I do think (select) is more idiomatic (and works as long as you don’t call the (look $) elsewhere), but it always bugged me that the visited flag was set before looking, because the documentation says that “the narration predicates are queried before the game world is modified”.
Granted, we could argue that (look $) is not a narration predicate, and that the visited flag is set after the player moving (but I haven’t checked) and it just happens that looking occurs after that, but still. I still find that checking the visited flag in the look is a useful pattern.
Yeah, the reason ($ is visited) gets updated before calling (look $) is because that flag is set in (update environment around player), the predicate that (among other things) checks for light and moves backdrops and floating objects into the room. So that always needs to happen before (look $) takes over, otherwise backdrops wouldn’t appear in the room description.
But, that could potentially be changed so ($ is visited) gets set in the rules for the LOOK action itself, after the call to (look $). That would have a few knock-on changes—if you LOOK inside a closed container, it would make the most sense implementation-wise for the ($ is visited) flag to get set on the container, not the room. But that doesn’t necessarily seem like a bad thing.
Either way is fine; a select-statement in the form (select) (or) (stopping) (that is, exactly two options, stopping on the second one) is converted to exactly what you’re doing during compilation (setting and then testing a flag).