Indefinite article problem with new action: digging

This might be a newbie question, as I’m only starting to learn Inform for my first game based on Jack and the Beanstalk. I’d like to make “dig”, “dig hole”, and “dig a hole” attempt to do precisely that, giving a special message in a certain location. It just so happens that one of my locations already has “a hole” as a separate thing. Here’s the relevant code:

[code]Digging is an action applying to nothing. Understand “dig”, “dig hole”, “dig a hole”, “dig a”, “dig in ground”, “dig a hole in the ground”, “dig hole in ground”, “dig a hole in ground”, and “dig hole in the ground” as digging.

Instead of digging:
if the location is Outside the Castle:
say “Any hole you dig in the clouds immediately fills itself in, though I’m proud of you for trying.”;
otherwise:
say “Even if you find suitable place to dig a hole, there really isn’t any point.”

Digging in is an action applying to one thing. Understand “dig [something]” and “dig in [something]” as digging in.

A thing can be diggable or undiggable. A thing is usually undiggable.

Sanity-check digging in an undiggable thing:
if the noun is distant:
instead say “[The noun] [is-are] too far away to even attempt.”;
otherwise:
instead say “You can’t dig into [the noun].”

A storm cloud is scenery in Outside the Castle. Understand “clouds”, “nimbus”, and “cumulonimbus” as the storm cloud. The description is “A tranquil, white and fluffy expanse. There’s no evidence of the raging storm below.” The scent of the storm cloud is “a rainy day, with a hint of car exhaust”. The storm cloud is diggable.

Instead of digging in the storm cloud, say “Any hole you dig in the clouds immediately fills itself in, though I’m proud of you for trying.”

A peephole is scenery in Outside the Castle. Understand “hole”, “watch hole”, “aperture”, and “opening” as the peephole. The description is “I’d guess it to be a peephole in the door to spot salespeople and proselytizers, as even a castle in the sky won’t protect you. This one looks large enough for a person to fit through.” The peephole is distant.[/code]

Interestingly enough, “dig hole” is recognized as “digging”, but “dig a hole” is recognized as “digging in (the peephole)”. For some reason, including the indefinite article won’t allow the understands of digging to override the digging in (I’m really struggling for a better way to phrase the problem, haha). Any help is greatly appreciated!

Does the player mean digging in the peephole: it is very unlikely.

That should get the parser to prefer your custom syntax.

Thanks for the reply Victor (by the way, I really enjoy reading your blog, particularly your rpg adventures). Tried the code, but it doesn’t work. I think it’s because there isn’t a disambiguation problem with multiple holes (twss!). There’s only one hole in the room (the peephole), but should the player decide to “dig a hole”, the player is talking about a new hole which doesn’t exist yet.

That is peculiar. I played with it a bit and found something that seems to work, though:

Digging is an action applying to one thing.
Understand "hole" or "a hole" as "[hole]".
Understand "dig", "dig [something]", "dig in/into [something]", "dig [hole]" or "dig [hole] in/into [something]" as digging.

The middle line does the trick, by defining a new token that matches the phrases “hole” or “a hole”.

Specifically, here’s my full test story, simplified from your example code:

"Dig dug"

Include Plurality by Emily Short.

Digging is an action applying to one thing.
Understand "hole" or "a hole" as "[hole]".
Understand "dig", "dig [something]", "dig in/into [something]", "dig [hole]" or "dig [hole] in/into [something]" as digging.

A room has an object called the surface.

Rule for supplying a missing noun while digging when the surface of the location is not nothing: now the noun is the surface of the location.

A thing can be diggable or undiggable. A thing is usually undiggable.
A thing can be distant or nearby. A thing is usually nearby.

Check digging a distant thing:
	instead say "[The noun] [is-are] too far away to even attempt."
Check digging an undiggable thing:
	instead say "You can't dig into [the noun]."

Outside the Castle is a room.
A storm cloud is scenery in Outside the Castle. Understand "clouds" as the storm cloud.
The surface of Outside the Castle is a storm cloud.

Instead of digging the storm cloud, say "Any hole you dig in the clouds immediately fills itself in, though I'm proud of you for trying."

A peephole is distant scenery in Outside the Castle. Understand "hole" as the peephole.

Test me with "dig / dig hole / dig a hole / dig hole in clouds / dig a hole in the clouds / x hole / dig a hole in the hole".

Weird! If somebody can explain why this happens, I’d love to know.

(Good to hear that you’re enjoying my blog, busterwrites!)