I7: Requiring the an object be held for an action to succeed

I have written:

[code]Poking is an action applying to one thing. Understand “poke [something]” as poking.

Poking it with is an action applying to two things. Understand “poke [something] with [something preferably held]” as poking it with.[/code]

However, even with the “[preferably held]” token the action succeeds regardless of the second noun’s location. How do I restrict the action to succeeding only when the second noun is in the player’s possession?

Try “an action applying to one thing and one carried thing”:

"Poke"

The Testing Chamber is a room.

Poking is an action applying to one thing. Understand "poke [something]" as poking.

Poking it with is an action applying to one thing and one carried thing. Understand "poke [something] with [something preferably held]" as poking it with.

Carry out poking: say "You poke [the noun]."

Carry out poking with: say "You poke [the noun] with [the second noun]."

A table is fixed in place in the testing chamber. There is a stick on the table.

Test me with "poke me / poke me with stick / poke me with table".

Note that this method causes an implicit take rather than failing the action when the second noun is not held.

Out of interest, how would I create an implementation of ‘poke’ whilst avoiding the implicit take?

You could try something like this:

Check poking something with when the second noun is not carried: say "You have to be holding [the second noun] before you can poke something with it." instead.

Not sure I’ve got the syntax at the beginning exactly right.

Note that this can wind up annoying your players, who wind up having to type three times as much if they try poking with something they’re not carrying.

You could also do something like this.

[code]An action-processing rule (this is the advanced carrying requirements rule):
if poking something with begin;
say “You need to be holding that first!” instead;
otherwise;
anonymously abide by the carrying requirements rule;
end if.

The advanced carrying requirements rule is listed instead of the carrying requirements rule in the action-processing rulebook.[/code]

The advantage here is that you can deal with multiple actions in one fell swoop here, otherwise you could use a before rule like the one mentioned below if it just applies to the one action.

The syntax is right, but it fires way too late do to any good. You’d need a before rule here.

Before poking something with something not carried: say "You have to be holding [the second noun] before you can poke something with it." instead.

Hope this helps.

I’m a little confused. Would you mind explaining the difference in efficiency between the two examples? Do you mean that the first example is better as I could include all my overrides within one block, as opposed to multiple ‘before’ statements? As I understand it, they both produce the same result and take a similar amount of of code to implement.

Oh, I forgot to say that if you are going to use a “check” rule then you have to keep “Poking it with is an action applying to two things.” rather than “Poking it with is an action applying to one thing and one carried thing.”

Exactly! You could easily do something like this.

[code]An action-processing rule (this is the advanced carrying requirements rule):
if poking something with or inserting something into or putting something on or eating or drinking … begin;
say “You need to be holding that first!” instead;
otherwise;
anonymously abide by the carrying requirements rule;
end if.

The advanced carrying requirements rule is listed instead of the carrying requirements rule in the action-processing rulebook.[/code]

Hope this helps.

That should work, although you’d probably need to remove the “[something preferably held]” token and use the “[something]” one instead.