Browsing Writing in Inform (as one does) I came across section 24.6 which describes a handy way to check for things with missing descriptions:
When play begins (this is the run property checks at the start of play rule):
repeat with item running through things:
if description of the item is "":
say "[item] has no description."
I added it to a game I’m working on, and instantly found a bunch of missing descriptions, but also:
*** Run-time problem P10: Since nothing is not allowed the property “current value”, it is against the rules to try to use it.
This was very odd to me, since all the items in my game have working descriptions when testing them interactively. I spent some time trying to find a minimal test-case, and eventually wound up with this:
Laboratory is a room.
Inside the Laboratory is an unbreakable beaker.
The description of the beaker is
"A chipped beaker labelled '[printed name]'."
When run normally, EXAMINE BEAKER reports “A chipped beaker labelled ‘unbreakable beaker’.” just as I expected. However, when adding the “check for missing descriptions” snippet, at the start of play I get:
*** Run-time problem P11: Although nothing is allowed to have the property “printed name”, no value was ever given, so it can’t now be used.
This particular situation is easy to work around: when the value “noun” is substituted in text, Inform always replaces it with the printed name of the current noun, so we can say:
The description of the beaker is
"A chipped beaker labelled '[noun]'."
…and that works with no runtime error.
However, that wasn’t quite the original situation I encountered. In my game I want to have dials that can be turned to a number, and the dial’s description should tell the player what number it’s turned to:
A dial is a kind of thing.
A dial has a number called the current value.
The current value of a dial is usually 5.
The description of a dial is usually
"The mark is turned to point at [current value].".
Inside the Laboratory is a dial called the brass dial.
Again, this works as I expected (EXAMINE DIAL produces “The mark is turned to point at 5.”) until the “check for missing descriptions” snippet is added, which produces a runtime error when the game begins:
*** Run-time problem P10: Since nothing is not allowed the property “current value”, it is against the rules to try to use it.
Unlike the simpler “printed name” example, this can’t be worked around by referring to the noun. This code:
The description of a dial is usually
"The mark is turned to point at [current value of the noun]".
…results in the same P10 error.
For people who want to play around with alternative approaches, I put all the above examples in a Borogove snippet.
As suggested by Writing with Inform, I have the “check for missing descriptions” snippet in a “not for release” section. As a result, runtime error only appears in debug builds, and the game seems to work properly, so I could ignore the runtime error. However, I worry that I am somehow abusing Inform’s mechanisms in a way that will cause problems later, so I’d like to fix it.
Is there some obvious thing I’m doing wrong? Perhaps descriptions aren’t supposed to have substitutions?
The text of these runtime errors suggests to me that in the “check for missing descriptions” snippet, the phrase “description of the item” is some how referring to the description but forgetting the item it’s attached to. As a result, Inform tries to evaluate phrases like “printed name” and “current value” without an item those properties could be attached to, and throws an error. Is there some way to reassure Inform “hey, we are talking about this item now” so it doesn’t get confused?