lynn
lynn

Reputation: 10794

How to write “dependent” understanding-when rules?

I’m in a situation like this:

"Cream Corner" by Lynn

An ice cream cone is a kind of edible thing.
An ice cream cone has a number called scoop count.

Rule for printing the name of an ice cream cone:
    say "[the scoop count in words]-scoop ice cream cone". 

The Cream Corner is a room.
The player holds an ice cream cone with scoop count 3.

Now I want > eat three-scoop to work. I can do this:

Understand "one-scoop" as an ice cream cone
    when the scoop count of the item described is 1.
Understand "two-scoop" as an ice cream cone
    when the scoop count of the item described is 2.
Understand "three-scoop" as an ice cream cone
    when the scoop count of the item described is 3.
[ ... ]

But of course, ideally, I’d like to write a rule like this:

Understand "[number]-scoop" as an ice cream cone
    when the scoop count of the item described is the number understood.

However, the Inform documentation specifies that this is impossible:

So we cannot safely say "when the noun is the fir cone", for instance, or refer to things like "the number understood". (We aren't done understanding yet.) If we want more sophisticated handling of such cases, we need to write checking rules and so on in the usual way.

All the same, it isn’t clear to me how to replace such a rule with a checking rule “in the usual way”. How do I use checking rules to make [number]-scoop in the player’s command be interpreted as “an ice cream cone with that many scoops”?

Upvotes: 2

Views: 77

Answers (1)

Eli Zupke
Eli Zupke

Reputation: 184

I'm not quite sure what the documentation is implying we do there, but I can help solve the base problem. A partial solution is these two lines:

Understand the scoop count property as referring to an ice cream cone.
Understand "scoop" as an ice cream cone.

This allows the player to type things like three scoop cone or three ice cream cone, and have the three-scoop cone be understood.

This is only a partial solution, as we don't include the dash*, so something like take three-scoop cone wouldn't be understood correctly. The obvious way of solving this problem is by replacing the dash entirely before the command is read, something like this:

[Nonfunctional solution!]
After reading a command:
    If the player's command includes "-scoop":
        replace the matched text with " scoop";

This doesn't seem to work however, as the above rule matches only whole words--i.e., three -scoop, but not three-scoop. Attempting to do the same with only replacing - fails similarly.

*You can also argue that three ice cream cone shouldn't be a valid match.

Upvotes: 3

Related Questions