Problems with digging

#1

In the game you need to dig a hole in Your Garden with a spade. I’ve tried the following which compiles without error but when I type ‘dig’ in the game is says 'You must supply a noun."

The spade is a thing.

The spade is inside the shed.

Description of spade is “It’s an excellent spade, in fact you might say it was the ace of spades.”

A hole is a transparent container.

A hole is nowhere.

A carrot is a thing.

The carrot is inside the hole.

Understand “dig” or “dig hole” or “use spade” as digging. Digging is an action applying to one thing.

Instead of digging Your Garden:
say “You dig a hole”;
now the hole is inside Your Garden.

Instead of digging Your Garden when the player does not carry the spade:
say “You need something to dig with!”

Instead of digging when the player is not inside Your Garden:
say “You can’t dig here!”

0 Likes

(matt w) #2

When you write “digging is an action applying to one thing” it creates an action that expects a noun. Then it’s possible to write an understand without a noun, as you did, but Inform expects that this means that you’re allowing the player to enter an incomplete command so it can prompt for a noun. Look up the “supplying a missing noun” activity in the documentation–that’s what incomplete understand lines are good for.

If you really want the action to be prompted by “dig” alone you should write “Digging is an action applying to nothing.” Then change “Instead of digging your garden” to “instead of digging in your garden,” since the action doesn’t take a direct object anymore and you want to change the location. (You should also add a check for whether the hole is already there.)

A warning from a design point of view–your Understand lines should try to avoid hard-coded phrases like “use spade.” That won’t capture “use the spade” for instance, and any other synonyms you have for “spade,” and also if “use spade” works the player will try to use other things and get confused by “That’s not a verb I recognize.” Or they will try to use other things, get “that’s not a verb I recognize,” and then they’ll never try “use spade.” One thing you could do is create a “using” action which redirects to digging for the spade and to other appropriate things for other objects (or says “Try something more specific.”)

Something similar applies to “dig hole” although that’s a bit more tricky since the hole won’t be there when the player tries to dig it. You could have another action that does apply to one thing that allows that, but you’d need some tricks:

[code]Object-digging is an action applying to one visible thing: [“visible thing” means "A thing that the parser understands, even if we can’t touch it–it’s less restrictive than “a thing”]

Understand “dig [any thing]” as object-digging. [“any thing” means anything in the game world whatsoever, whether or not it’s in the room or even on-stage.][/code]

In fact you could make this the main action and use the supplying a missing noun activity to take care of the command “dig”:

[code]Digging is an action applying to one visible thing: [“visible thing” means "A thing that the parser understands, even if we can’t touch it–it’s less restrictive than “a thing”]

Understand “dig [any thing]” as digging. [“any thing” means anything in the game world whatsoever, whether or not it’s in the room or even on-stage.]

Understand “dig” as digging. [this means that when the player types “dig” the game will run the supplying a missing noun activity instead of just complaining]

For supplying a missing noun when digging: now the noun is the hole. [and this means that “dig” gets converted to digging the hole.]

Instead of digging something: say “That can’t be dug.” instead.

Instead of digging the hole when the location is not the Garden: say “You can’t dig a hole here.”

Instead of digging the hole when the location is the Garden and the hole is in the garden: say “You’ve already dug a hole.”

Instead of digging the hole when the location is the Garden and the hole is nowhere:
say “You dig a hole.”;
now the hole is in Your Garden.
[/code]

I should warn you that I can’t run Inform right now so I’m not sure this code will work just right, or at all.

0 Likes

#3

That works a charm, thank you.

I know what you mean about ‘use’, causes all kind of issues in Quest too (which I’m currently migrating from).

Cheers.

0 Likes