In my game someone spills some coffee and they then have to clean it up. I want the game to be able to recognise the phrase “clean coffee” as a valid way to clean another object called coffeestain.
In play once the coffee is spilled it goes to nowhere and the coffestain springs into existence.
every turn when the coffee is nowhere:
understand "coffee" as the coffeestain.
If you have a moment, what was the fundamental issue with my construction, from a language perspective? This might highlight a larger issue in my coding syntax.
Understand lines are declarations which stand alone, just like:
The Lab is a room.
The ball is in the Lab.
Within rules (such as “every turn”) you need to use phrases, such as:
if the ball is in the Lab....
[or]
now the rock is nowhere
One (I believe) undocumented, but standard convention of the documentation (Writing with Inform) is that the former is always capitalized and the latter is not. This is not a syntactical requirement of the language, but it is a good way to keep the two concepts separated in your mind.
It’s also generally a good idea to avoid every turn rules because those will fire every turn. In your case, even if hypothetically the syntax works, there is no point in declaring the coffee stain every turn when you only need to spring it into existence once.
Inform has a distinction between declarative statements—establishing facts about the world that are true in general, like “understand” lines—and imperative statements—commands for the computer to carry out under particular circumstances, like “every turn” rules.
In general, everything inside a rule is imperative, and everything outside a rule is declarative. This is why you can say “the coffee is in the pot” in declarative code, but have to say “now the coffee is in the pot” in imperative code. “Now” makes a statement into a command.