Waking inanimate things

In Inform 6M62, I’ve added these lines to allow the player to attempt to wake an inanimate object. I adapted these lines from the “Typed commands leading to this action” section of the Actions index, so I think these are equivalent to the built-in understand lines used for waking people, but with the “something” token. (I doubt anyone would ever type “awaken up,” but whatever.)

Understand “wake [something]” as waking.
Understand “awake [something]” as waking.
Understand “awaken [something]” as waking.

Understand “wake [something] up” as waking.
Understand “awake [something] up” as waking.
Understand “awaken [something] up” as waking.

Understand “wake up [something]” as waking.
Understand “awake up [something]” as waking.
Understand “awaken up [something]” as waking.

This mostly seems to be working, but I’m running into an issue where if the player character is in a different room from certain inanimate objects, trying to wake the thing gives the response “You can only do that to something animate,” when I was expecting the response “You can’t see any such thing.”

Here’s an example:

Understand "wake [something]" as waking.
Understand "awake [something]" as waking.
Understand "awaken [something]" as waking.

Understand "wake [something] up" as waking.
Understand "awake [something] up" as waking.
Understand "awaken [something] up" as waking.

Understand "wake up [something]" as waking.
Understand "awake up [something]" as waking.
Understand "awaken up [something]" as waking.


Room 1 is a room. "This is Room 1. To the south is Room 2."

A statue is in Room 1.

A pink paintbrush is in Room 1.


Room 2 is a room. Room 2 is south of Room 1.

A woman called Rachel is in Room 2.

A pencil is in Room 2.

An eraser is a kind of thing.

A pink eraser is an eraser in Room 2.

A white eraser is an eraser in Room 2.

Test me with "wake white eraser/wake pink eraser".

Output:

Room 1
This is Room 1. To the south is Room 2.

You can see a statue and a pink paintbrush here.

>test me
(Testing.)

>[1] wake white eraser
You can't see any such thing.

>[2] wake pink eraser
You can only do that to something animate.

If I comment out the pink paintbrush in the code, I get this output instead (which is what I would expect):

Room 1
This is Room 1. To the south is Room 2.

You can see a statue here.

>test me
(Testing.)

>[1] wake white eraser
You can't see any such thing.

>[2] wake pink eraser
You can't see any such thing.

Any suggestions?

I have no idea why this is happening, but I’d recommend removing those lines from the Standard Rules (via “understand…as something new” or section replacement); that seems easier than getting into the parser guts.

(Well, I have a bit of an idea. During the parsing process, the parser has a hierarchy of errors, and it only reports the highest-ranking one it came across. Apparently “only animate” ranks higher than “noun was only a partial match”.)

1 Like

I like the idea of starting over–thanks!

Here’s what I’ve got now. So far it seems to be working.

Understand nothing as waking.

Awakening is an action applying to one visible thing.

Understand "wake [something]" as awakening.
Understand "awake [something]" as awakening.
Understand "awaken [something]" as awakening.
Understand "wake [something] up" as awakening.
Understand "wake up [something]" as awakening.

Check awakening (this is the block awakening rule):
	if the noun is a person:
		say "[The noun] [are] already awake." instead;
	otherwise:
		say "That seems unnecessary." instead.

(And instead rules to deal with certain cases.)

The diagnosis by Draconis is correct. The error-reporting behavior can be changed, but, as he suggests, it’s less trouble to avoid the “something animate” error in the first place.

Instead of creating an entirely new action (which does indeed prevent the conflict), you could just redefine the existing grammar to remove the animation requirement for the waking action. The Standard Rules includes these relevant lines:

Understand "wake" or "wake up" as waking up. [for the waking up action, not the waking action]
Understand "wake [someone]" or "wake [someone] up" or "wake up [someone]" as waking.
Understand the commands "awake" and "awaken" as "wake".

which by default shows the following debugging output for the command >SHOWVERB WAKE:

Verb 'awake' 'awaken' 'wake' 
	 * -> Wake
	 * 'up' -> Wake
	 * creature -> WakeOther
	 * creature 'up' -> WakeOther
	 * 'up' creature -> WakeOther

The >SHOWVERB debugging command is not well known, but it is very useful in a case like this. With your original changes, you end up with the following:

Verb 'awake' 'awaken' 'wake' 
	 * -> Wake
	 * 'up' -> Wake
	 * creature -> WakeOther
	 * noun -> WakeOther
	 * noun -> WakeOther
	 * noun -> WakeOther
	 * creature 'up' -> WakeOther
	 * 'up' creature -> WakeOther
	 * noun 'up' -> WakeOther
	 * noun 'up' -> WakeOther
	 * noun 'up' -> WakeOther
	 * 'up' noun -> WakeOther
	 * 'up' noun -> WakeOther
	 * 'up' noun -> WakeOther

As you can see, the old grammar lines don’t go away, so the error codes for them are still generated when they fail (and error messages for them displayed when they take priority). The changes that you really need boil down to just

Understand nothing as waking.

Understand "wake [something]" or "wake [something] up" or "wake up [something]" as waking.

which leaves the grammar at

Verb 'awake' 'awaken' 'wake' 
	 * -> Wake
	 * 'up' -> Wake
	 * noun -> WakeOther
	 * noun 'up' -> WakeOther
	 * 'up' noun -> WakeOther

which is identical to the original grammar except that it does not use the [someone] token and will not trigger a conflict in error messages.

Note that the only action-processing rule in the Standard Rules for this action is

Check an actor waking (this is the block waking rule):
	if the actor is the player:
		now the prior named object is nothing;
		say "That [seem] unnecessary." (A);
	stop the action.

so default behavior depends on the parser-generated errors to point out to the player that something can’t be expected to wake up. You would want to add at least one new check rule to handle inanimate objects if you want to provide more specific feedback.

3 Likes

Thanks for the explanation! I think removing the “touchable” requirement is going to make my life easier, though. I’ll probably stick with the new action so that I can make it apply to any visible thing.

1 Like