[I7] Stored action with ambiguous nouns?

I’m trying to create an all purpose “use” action, and then to support things that act on other things, a “use on” action. The use action works pretty well (for example, “use potion” just drinks the potion). Use on, however, is a bit of a problem. Here’s the relevant code:

[code]A thing has a stored action called a use case.

Using is an action applying to one touchable thing. Understand “use [thing]” as using.

Check using:
if the use case of the noun is waiting:
say “You aren’t entirely sure how to [italic type]use[roman type] this, so you take a closer look instead…[line break]”;
try examining the noun;
stop the action.

Carry out using:
try the use case of the noun.

Using on is an action applying to two touchable things. Understand “use [thing] on [thing]” as using on.

Check using on:
if the use case of the noun is waiting:
say “You, uh, use [the noun] on [the second noun]. Neither looks very pleased.” instead.

Carry out using on:
try the use case of the noun.[/code]

As you can see, for the “use on” action, my carry out command doesn’t actually use both things. That’s because I’m not quite sure how to do so. The object in particular I want to use is a lockpick that can work on multiple doors, so I can’t just make the stored action of the lockpick have an absolute thing it works on. Here’s where the lockpick’s use case is initialized:

The use case of the lockpick is the action of unlocking something.

Any ideas?

It looks like you want to insert the second action into the lockpick’s stored action, and then execute it. The “Editable Stored Actions” extension will let you do this.

But you’re going a long way around to make this work. You could drop the stored action entirely, and just have rules like

The player carries a lockpick.
The player carries an apple.

Using is an action applying to one touchable thing. Understand "use [thing]" as using.

Carry out using the apple:
	instead try eating the apple.
	
Carry out using:
	instead say "You're not sure how."
	
Using it on is an action applying to two touchable things. Understand "use [thing] on [thing]" as using it on.

Carry out using the lockpick on:
	instead try unlocking the second noun with the lockpick.

Carry out using it on:
	instead say "You, uh, use [the noun] on [the second noun]. Neither looks very pleased."

You wind up writing a rule for every object that you want “use” to work on, but that’s the same amount of work as in your scheme (writing a use case property for every such object). You don’t need a special check rule because the generic case is handled at the end of the carry out rules.

You probably don’t even need to make a use action. Here’s what we do in Kerkerkruip:

Understand the command "equip" as "use". Understand "use [clothing]" as wearing. Understand "use [scroll]" as reading. Understand "use [grenade]" as throwing. Understand "use [fungicide contraption]" as spraying. Understand "use [weapon]" as readying.

The Kerkerkruip model (restricted grammar lines) can work, but you have to watch out for a few things.

  • If an object doesn’t fall into one of the noun classes, the parser will say “You can’t see any such thing,” even though the object is present. This can wreck your player’s faith in a hurry.
  • The parser can’t disambiguate across grammar lines. This means that “use bronze” can never result in the question “Which do you mean, the bronze helmet or the bronze dagger?” even if that’s appropriate. (It will just pick the first matching line.)
  • You still need a “use it on” action for the lockpick, because that action takes two nouns. You also need a custom action for any case that requires additional code.

You can avoid the first problem by adding a final catch-all grammar line:

Understand "use [something]" as generic-using.

DTPM rules may be able to handle the use it on action, or maybe not. They’re kind of a dark art.

Zarf’s method is definitely more thorough, but I thought I’d share ours just in case it helps with the simpler cases.

Really? Huh, I didn’t know that!