I want the player to be able to give a set of commands to an NPC and have that NPC follow the commands, but it seems that the NPC performs the first command without waiting to hear the rest. For example:
>Alice, go north then ask queen about the pardon and then go south.
Alice goes north.
You seem to want to talk to someone, but I can't see whom.
How do I get Alice to listen to all the player has to say before carrying out the commands.
Here’s my source code so far:
The antechamber is a room. Alice is a woman in the antechamber.
The throne room is north of the antechamber. The Queen is the woman in the throne room. The pardon is in the throne room.
Persuasion rule for asking people to try going: persuasion succeeds.
Persuasion rule for asking people to try asking about: persuasion succeeds.
Alice, go north. Ask queen about the pardon. Go south.
Since Alice has to go north where the queen is, it thinks YOU are trying to ask the queen about the pardon, but she’s to the north and not in scope for you.
Maybe try: Alice, go north then alice, ask the queen about the pardon then alice, go south.
The problem with that one is that in the first turn Alice goes north, which means in the second turn you can’t talk to Alice because she’s not there. (“then” is interpreted as a command separator at the top level, and in general only one action is permitted per turn.)
I don’t think there’s any good solution for this, it’s just not how the parser was designed to operate. As a story author, you could perhaps have Alice understand more abstract concepts like “Alice, execute plan zebra!”
Exactly this. The parser is executing commands in sequence on different turns. Alice doesn’t “remember” what you told her to do. You’d have to turn some coding backflips to make that happen. Plan zebra is a good option, or some narrative NPC autonomy.
I think Gavin has the right diagnosis here–the parser keeps trying to interpret the separated commands as addressed to Alice, and after Alice goes north she’s not in scope anymore. If you try chained commands that don’t take Alice out of the room, they seem to work:
>alice, jump then wait then go north
Alice has better things to do.
Alice has better things to do.
Alice goes north.
except that Alice has better things to do.
A way to address this that doesn’t involve too many coding backflips is to notice when you’ve asked someone to do something, record who you asked to do it, and keep that person in scope until the next time you read a command:
The antechamber is a room. Alice is a woman in the antechamber.
The throne room is north of the antechamber. The Queen is the woman in the throne room. The pardon is in the throne room.
Persuasion rule for asking people to try going: persuasion succeeds.
Persuasion rule for asking people to try asking about: persuasion succeeds.
First command was persuasion is a truth state that varies.
The person really asked is a person that varies.
After reading a command: now first command was persuasion is false. [This may get a bit touchy with disambiguation, but this probably isn't going to play nicely with disambiguation anyway]
Before a person (called the NPC) doing something when first command was persuasion is false:
now first command was persuasion is true;
now the person really asked is the NPC.
After deciding the scope of the player when first command was persuasion is true:
place the person really asked in scope.
(“a person doing something” only applies to persons who are not the player–see §12.14 of Writing with Inform. This messed me up for a while when I was trying to code it!)
One thing, though, is that this does not work at all with actions applying to a topic… like asking it about. The parser will interpret the “Alice, ask the queen about the pardon then go south” part of the command as Alice asking the queen about “the pardon then go south.” I think this is probably baked real deep in the parser and unrelated to the scope issue. Also I think any parser error will get interpreted as asking Alice about something and cut off the rest of the chain of processing, though that’s kind of inevitable with parser errors. But if you stick to commands involving things like “Alice, go north then show the queen the pardon then go south” then it does seem to work (though again, Alice has better things to do then show the queen the pardon).