# Digging (looking to see if there is a less messy way)

Working on puzzle mechanics and I ended up wanting a puzzle where the player uses a map an coordinates to find something that is buried outside, and ended with this, i kinda get the feeling that there might be a better way though.

[code]“Testing labs” by Ryan Porter

A tool is a kind of thing. Tools can be shoveling.
Rooms can be indoor or outdoor.
Digging is an action applying to nothing. Understand “dig” as digging.
h is a number that varies.
When Play Begins: Now h is 0.
Starter is a number that varies.
When Play Begins: Now Starter is 0

Select is a recurring scene.
Select begins when starter is 1.
Select ends when starter is 2.

When Select begins:
Say “You open up your map”;
Say “.[description of map]”;
Now the command prompt is “Where would you like to dig>”.

When Select Ends:
Now the command prompt is “>”.

Check digging:
If the player does not enclose a shoveling tool, say “you don’t think you could make much headway with your fingernails.” instead;
If the player is in an indoor room, say “you shouldn’t dig up the floor.” instead;
If the player does not enclose the map:
if h is less than 3:
say “you dig around a bit”;
increase h by 1;
otherwise:
say “maybe you should get some direction as to where to dig.”;
If the player encloses the map:
Now starter is 1

Instead of doing something other than A1, A2, B1 or B2 during Select:
say “that isnt a location on the map”;
now starter is 2.

A1 is an action applying to nothing. Understand “A1” as A1.
A2 is an action applying to nothing. Understand “A2” as A2.
B1 is an action applying to nothing. Understand “B1” as B1.
B2 is an action applying to nothing. Understand “B2” as B2.

Check A1:
if Select is happening:
say “you dig for a while but find nothing”;
Now starter is 2;
otherwise:
say “That’s not a verb I recognise.”.

Check A2:
if Select is happening:
say “you dig for a while but find nothing”;
Now starter is 2;
otherwise:
say “That’s not a verb I recognise.”.

Check B1:
if Select is happening:
say “you dig for a while and find a dingy hat”;
Now the hat is in the laboratory grounds;
Now starter is 2;
otherwise:
say “That’s not a verb I recognise.”.

Check B2:
if Select is happening:
say “you dig for a while but find nothing”;
Now starter is 2;
otherwise:
say “That’s not a verb I recognise.”.

The dirty hat is a thing. “this old hat has seen better days”.

The laboratory grounds is an outdoor room. In the laboratory grounds are a map and a spade. The spade is a shoveling tool.
The laboratory lobby is an indoor room. The lobby is north of the grounds.
The description of the laboratory grounds is “A large open space in front of the lab (to the north).”.
The description of the laboratory lobby is “A small lobby that leads to the experimentation lab, its after hours so everything is locked down tight, the door (to the south) leads out to the grounds”.

The spade is a shoveling tool. The description of the spade is “A small shovel.”. Understand “shovel” as spade.
The description of the map is “A map of the grounds printed out on white paper, a corner of the property is devided up into four quadrents labeled A1, A2, B1 and B2. B1 is circled.”.

test me with “get all / dig / A1 / dig / A2 / dig / B1 / dig /B2 / get hat.”[/code]

I’m not sure I follow everything that the code is trying to do, but here’s one way to prompt the player to choose a quadrant:

[code]A quadrant is a kind of scenery thing. A1, A2, B1, and B2 are quadrants. Every quadrant is in Laboratory Grounds.

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

Rule for supplying a missing noun while digging:
now noun is the location.

Say “Where do you want to dig?”.

A1ing is an action applying to nothing. Understand “A1” as A1ing.
Instead of A1ing, try digging A1.

A2ing is an action applying to nothing. Understand “A2” as A2ing.
Instead of A2ing, try digging A2.

B1ing is an action applying to nothing. Understand “B1” as B1ing.
Instead of B1ing, try digging B1.

B2ing is an action applying to nothing. Understand “B2” as B2ing.
Instead of B2ing, try digging B2.[/code]

But, I am far from an expert, so maybe there’s a better way.

Ah cool, that is much… much cleaner. I had wanted to go about it in a way that only made the quadrants (or more likely later on larger amount of divisions) available when using the map as a reference, but I suppose player knowledge would cover that.

I also wanted the player to be able to dig around a little before receiving the error message, but also keep some things hidden until later. so basically digging when holding the map brings up a ‘menu’ that limits the players actions to selecting a place to dig, or canceling out of the action. I mean it does what I want, but its a bit all over the place.

Well, you could have the quadrants start offstage, and then move the quadrants into the location when the player looks at the map for the first time. Then you could make the instead rule dependent on the quadrants already having been moved into the location, and on the player holding the map:

```Instead of digging Laboratory Grounds when the location encloses a quadrant and the player encloses the map: Say "Where do you want to dig?".```

Hmm, I’m not sure of the best way to do that. Maybe the Questions extension by Michael Callaghan? Or maybe someone else will have a suggestion.

Note–I had to edit the “understand” line in my previous post to get the “supply a missing noun” part to work.

I was going to say that you can get Inform to automatically take a quadrant as an answer to the “Where do you want to dig?” question–that’s the out-of-the-box behavior for the response to “dig” when “dig [something]” has an Understand line and “dig” by itself doesn’t. But it turns out to be really hard to get Inform to understand when to print the special “Which quadrant do you want to dig in?” question! I had to put it into one of the internal response messages, and also use an I6 hack of zarf’s to get the name of the half-completed question. (Maybe you can use that “command so far” thing that shows up in the normal message to take care of this–I’d never seen it before.)

Also if you only have one thing in your inventory, the parser obnoxiously decides that that must be what you want to dig. (Maybe this is something special that happens when there’s only one non-scenery thing in the location?) That stinks.

Anyway, here’s the code:

[code]Laboratory Grounds is a room.

A dingy hat is a thing.

A quadrant is a kind of scenery thing. A1, A2, B1, and B2 are quadrants. Every quadrant is in Laboratory Grounds. A quadrant can be dug.

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

Check digging when the noun is not a quadrant:
say “You can’t dig that.” instead.

Check digging Laboratory Grounds:
Say “You must specify a quadrant: A1, A2, B1, or B2.” instead.

now the noun is dug.

Carry out digging B1 when the hat is off-stage: [shouldn’t need to verify that the hat is off-stage, because that should get stopped by the “dug quadrant” check rule, but better safe than sorry]
now the player carries the hat.

After digging B1: [the After rule preempts the Report rule]
say “You find a hat!”

Report digging:
say “You don’t find anything.”

To decide which action name is the action to be: (- action_to_be -).

When play begins:
now parser clarification internal rule response (E) is “[if the location is the Laboratory Grounds and the action to be is the digging action]Which quadrant do you want to dig: A1, A2, B1, or B2?[otherwise]What do you want to [parser command so far]?”[/code]

Since this has problems, a better way to do it might be just to include a line like this:

``Understand "[quadrant]" as digging [when the player holds the map and the location is the Laboratory Grounds and whatever other conditions you need].``

This will have “A1” be understood as digging A1 without needing to make four customized actions.

Ooh, I didn’t know you could make the command do double-duty like that (both action and noun in one). That’s neat.