Asking or telling the NPC to try doing something in Inform 7

[SOLVED]

Hi all,

I’ve nearly driven myself mad searching for an answer to this one for the past few days:

I would very much like Inform 7 to understand "ASK [something] TO [text]" and "TELL [something] TO [text]" as {ASKING IT TO TRY}. .

It seems that ‘asking it to try’ isn’t recognized, unlike ‘asking it about’, ‘asking it for’, ‘telling it about’, or ‘answering it that’, so I know ‘asking it to try’ is incorrect. (I just put it there as a placeholder.)

I’m also not certain that [text] is the correct grammar token.

I currently have this dirty hack setup for asking or telling the NPC to jump or attack:

[code]
Understand “ask [something] to [text]” as answering it that.

Understand “tell [something] to [text]” as answering it that.

instead of answering something (called the instructed) that something when the player’s command includes “say/tell”:
say “Try entering that command this way: [The instructed], [the topic understood]”.

before trying answering something (called the instructed) that something when the player’s command includes “jump” and the player’s command includes “say/tell”:
try the instructed jumping;
rule succeeds instead.

commanding a kill is an action applying to two things.

understand “tell [something] to kill/attack/murder/fight/shoot/cut/stab/decapitate/destroy [something]” as commanding a kill.

carry out commanding a kill:
try asking the noun to try attacking the second noun.[/code]

This pulls it off, but I’d have to write a line for each action that the NPC could possible perform, and I bet there is a much more precise method.

Anyone every dealt with this or have any ideas (or even good links)?

Thanks in advance!

The format “ask [someone] to try [doing something]” is how you refer to the action inside the game’s code. There’s no grammar set up to allow the player to use that construction in the game, and there’s no way to do so without doing insanely complicated things in the I6 layer.

The normal way to handle giving a command to an NPC, from the player’s perspective, is to address the NPC directly, like this:

From the coding perspective, you handle the input by using a persuasion rule:

Persuasion rule for asking Mike to try killing the hobo: say "Mike looks at you as if you'd suddenly sprouted a second head. "Uh, no thanks."; persuasion fails.

If you want the persuasion to succeed, just say so:

Persuasion rule for asking Mike to try killing the hobo: persuasion succeeds.

…and then you write some carry out and reporting rules to handle what happens when Mike kills someone.

By the way, you CAN get the game to understand player input in the format “ASK [someone] TO [do something]”, with a bit of pre-parsing trickery:

After reading a command (this is the phrasing commands properly rule): let N be "[the player's command]"; replace the regular expression "^(ask|tell|order) (.+?) to (.+)" in N with "\2, \3"; change the text of the player's command to N.

This converts the command from “ASK MIKE TO KILL THE HOBO” to “MIKE, KILL THE HOBO” before the parser tries to make sense of it.

This is [SOLVED], but today is the first time I’ve posted, and I can’t figure out how to edit the subject line.

Thanks again!

Editing subject lines is not the usual convention around here. It’s fine to leave the thread alone once everyone’s done talking.

Yes, people will just come by and see that it’s solved–or if they use the “unread posts” function to monitor the board, they’ll stop looking at the thread when people stop posting on it. Unless someone bumps it, like I’m doing now. Oh well.

But if you ever do need to edit a subject line, you can edit the subject for your individual posts by clicking the “edit” button and editing the subject line above where you would edit the main text of the posts. This won’t change anyone else’s subject line, which is one reason why it’s not usually a great idea to do it–but if you ever post a new topic and realize you need to edit the subject line immediately after, that’s how to do it.

Oh, I see.

I’ve been conditioned to mark them closed. (Folks on some boards get quite nasty about it.)

This procedure sounds better to me. (And much more efficient.)

Thanks, matt w, zarf, and mikegentry!

You are all the Bee’s Knees, as far as I’m concerned.