Understand something as something inconsistent error

Good morning all.

I used the following snippet from last year’s game (I’m getting to be a real programmer now!) but it’s throwing an error based on the cleaning bit in my current one, which means that the error is elsewhere, and connected. Can anyone think of likely culprits? Could it be that polish is a verb and a noun and the object polish is in the game?

THE ERROR
Problem. You wrote ‘Understand “clean [something]” as cleaning’ [![]: but ‘understand … as …’ should be followed by a meaning, which might be an action (e.g., ‘understand “take [something]” as taking’),

THE CODE
Understand the command “polish” as something new.

Understand “polish [something]” as polishing.

Polishing is an action applying to one visible thing.

Understand the command “clean” as something new.

Understand “clean [something]” as cleaning.

understand the command “clean” as “polish”.

It looks like you defined polishing as an action, but not cleaning. If you want cleaning to just be a synonym for polishing, I suggest replacing the two lines I quoted with:

Understand “clean [something]” as polishing.

Another way is to just omit all of this altogether and use the pre-existing ‘rubbing’ action which these actins are already synonyms with. The problem with that is that writing ‘rubbing’ in the code might be confusing since you want to always have it mean ‘cleaning’.

Also, I would recommend dropping the word ‘visible’. I’ve been programming in Inform for 7 years now, but I still don’t really understand visible, but I know that here it would let you clean things you shouldn’t be able to touch. Here’s a thread about ‘visible’:

2 Likes

That certainly did the trick and as much as I’d like to dig into why it worked before and didn’t now, time prohibits such flights of fancy.

I had a conversation about rubbing as a command last year, either here or elsewhere, and I think I went with polishing as an academic exercise to better understand the process of creating an action rather than as a refutation of the existing command, which, as you say, covers what I want(ed) to do nicely.

To your second point, in my head visible related to objects that were “within reach” of the player, either physically or visually. I included it to prevent people polishing stuff they knew existed but couldn’t feasibly polish (you know how people like to polish stuff). I see it is unnecessary and I’ve removed it.

1 Like

Yep, there are two separate ways to restrict what the action applies to.

When you define the action, you can have it apply to a “thing” or a “visible thing”. The former means you need to touch the noun, while the latter doesn’t put any restrictions on it: taking applies to a thing, for example, but examining applies to a visible thing. (You can check this in play by asking “if the action requires a touchable noun” or “if the action requires a touchable second noun”.) There’s actually a third option here as well, a “carried thing”, which works exactly as you’d expect: it requires the noun to be held.

These restrictions, notably, have nothing to do with the parser. These are restrictions about the action, and mean the action will fail if the player specifies the wrong type of object (like TAKE FIGURINE when the figurine is in a locked display case).

When you write the Understand lines, you can also add restrictions there: the most common are [something] versus [anything], but you can get as precise as you want, like [a direction] or [any scenery backdrop]. If it starts with “some” or “a”, then it requires the object to be in scope, which usually means visible to the player character; if it starts with “any”, it does not have this requirement.

These restrictions apply to the parser, not to the action. If the restrictions are violated, the parser will give an error, like “you can’t see any such thing” or “I didn’t understand that sentence”; if you invoke them from game code instead of from the parser (“try examining the distant volcano”), it’ll work just fine.

This means that the most common patterns for an action are:

  • “Applying to one thing”, “[something]”. The parser requires the noun to be visible, and the world model requires it to be touchable. This is used for manipulating the world, like taking.
  • “Applying to one visible thing”, “[something]”. The parser requires the noun to be visible, and the world model puts no constraints on it. This is used for investigating the world, like examining.
  • “Applying to one visible thing”, “[anything]”. Neither the parser nor the world model puts any constraints on what can be specified. This is used for debugging commands, where you want to be able to affect anything in the game.

The fourth option, “applying to one thing” and “[anything]”, isn’t especially useful—it means the object doesn’t need to be in scope, but does need to be touchable, and that’s a pretty rare set of circumstances.

Is “[anything]” ever used for in-universe actions rather than debugging? Not very often. More often, you’ll want to give the parser an additional requirement, like “[any known thing]”. This is good for commands like FIND, which you want to apply to things outside the current room, but only ones the player has seen before. (“Known” is defined in the built-in extension Epistemology by Eric Eve, if you want to use this.)

2 Likes

That’s a great description. Thank you for taking the time to go into detail on those options. “A carried thing” will come in very handy in future.