problem getting other actors to perform actions

I’m having some trouble getting other actors to perform actions. Sometimes it fails on what seem like normal actions (Jay, enter) and sometimes on custom actions I’ve created. I think I’ve also created the action incorrectly (it reports whether or not it succeeded), but I’m not sure what’s the best way to do this. Here’s my code. Any ideas? Thanks!

[code]“test” by Caleb Wilson

Attic is a room.

Jay is a person in the attic.

Persuasion rule for asking Jay to try doing something:
persuasion succeeds.

The table is a supporter in the attic.

A thing can be tiny.

A thing can be sharp.

The piece of string is in the attic. It is tiny.

The piece of paper is in the attic. It is tiny.

The pair of scissors is in the attic. It is sharp.

Understand the command “cut” as something new.

Cutting it with is an action applying to one touchable thing and one carried thing.

Understand “cut [something] with [something]” as cutting it with.

Carry out cutting it with:
if the second noun is not sharp:
say “The [second noun] isn’t sharp enough.” instead;
if the noun is not tiny:
say “[The noun] is too large to cut.” instead;
otherwise if the noun is tiny:
remove the noun from play.

Report cutting it with:
if the actor is the player:
say “You cut [the noun] into tiny pieces.”;
otherwise if the actor is not the player:
say “[The actor] cuts [the noun] into tiny pieces.”

Test me with “cut string with scissors / cut table with scissors / drop scissors / jay, cut paper with scissors / jay, cut table with scissors / jay, jump / jay, enter”.[/code]

A few things:

Rules like “carry out cutting it with” only run for the player. If you want them to run for anyone you have to write “carry out an actor cutting something with something”–“an actor” lets the rule run for anyone, and “cutting it with” won’t work when we have “an actor.” See section 12.14 of Writing with Inform (and 12.11-12.14 more generally).

If you want an action to fail if a condition isn’t met, you have to put the condition in a “check” rule rather than a “carry out” rule. By the time you reach the carry out rules the action has succeeded. So you want to put stuff like the checks for sharpness and tinyness into check rules. (This is why your Report rules are running even though you have an “instead” in your Carry out rules.)

Also “[The actor]” will work if the actor is you, so you can consolidate those two cases into one, as long as you use the verb conjugation powers on “[cut]” which is probably a good idea anyway.

When an NPC tries something and fails, the “Unsuccessful attempt” rules run. This is what prints “Jay is unable to do that.” You can customize this with new rules, possibly involving “the reason the action failed” which tells you what rule stopped the action. See section 12.5 of Writing with Inform. (This can lead to another message printing after the Check rule has printed something, which is kind of annoying. In Terminator I had a whole lot of check rules that didn’t print anything with matching Unsuccessful Attempt rules which printed the corresponding message. There may be a more elegant way.)

…oh, and the response to “Jay, enter” looks like a bug to me. If you try “enter” yourself you get “you must supply a noun,” because you’re missing a noun, but I guess the For supplying a missing noun rule that prints that is written so as not to apply to NPCs? Anyway looks like we can write one.

Adding all this up I get:

[code]“test” by Caleb Wilson

Attic is a room.

Jay is a person in the attic.

Persuasion rule for asking Jay to try doing something:
persuasion succeeds.

The table is a supporter in the attic.

A thing can be tiny.

A thing can be sharp.

The piece of string is in the attic. It is tiny.

The piece of paper is in the attic. It is tiny.

The pair of scissors is in the attic. It is sharp.

Understand the command “cut” as something new.

Cutting it with is an action applying to one touchable thing and one carried thing.

Understand “cut [something] with [something]” as cutting it with.

Check an actor cutting something with something:
if the second noun is not sharp:
say “The [second noun] isn’t sharp enough.” instead;
if the noun is not tiny:
say “[The noun] is too large to cut.” instead;

Carry out an actor cutting something with something:
remove the noun from play.

To cut is a verb.

Report an actor cutting something with something:
say “[The actor] [cut] [the noun] into tiny pieces.”;

Unsuccessful attempt by Jay doing something: say “Jay shrugs helplessly.”

For supplying a missing noun when the person asked is Jay: say “Jay says, ‘You didn’t tell me what to do that to.’”

Test me with “cut string with scissors / cut table with scissors / drop scissors / jay, cut paper with scissors / jay, cut table with scissors / jay, jump / jay, enter”.[/code]

Don’t use that specific supplying a missing noun message, because the player will think they can just type the missing noun, and they can’t.

Thanks so much – this is awesome! Wow, I think I have some bad inform habits that always worked before now.

You’re welcome!

For what it’s worth that error seems to happen only with “Jay, enter.” (Which means you should change the supplying a missing noun rule to “For supplying a missing noun rule when Jay entering” or something like that.)