In a room with no objects other than the player and an NPC (let’s call him Bob), if I enter ask (without arguments) I get:
(Bob for Bob)
(Bob first taking Bob)
Bob has better things to do.
How can I control this response so that I don’t get the messages in parantheses to appear? They are kind of confusing
I’d say that depends upon what you want the response to be.
This will trigger a disambiguation question («What do you want to ask Bob for?»):
Does the player mean asking anyone (called agent) for the agent: it is unlikely.
You can find out what rules to intercept and what actions to modify by using the debug commands RULES and ACTIONS, respectively. After you have given these commands the Inform IDE will print information about what rules are considered and what actions are tried. (RULES OFF and ACTIONS OFF turn them off.)
Oh! I have to look up “does the player mean”. Thanks, that should take care of it.
A further question:
I’ve been experimenting with both TADS and Inform, and in TADS it is quite easy to use a regular expression for ASK someone ABOUT …
I know Inform does have regular expression support, but I have just not been able to make it work with “Instead of asking Bob about …”
Is there a simple solution to make this work, without creating a new ASK command or something like that? I really like using topic tables, and it’d be great if I could just have a regex as the topic string.
You can just loop through the table and check each entry for a match, like this:
Instead of asking Bob about some text:
repeat through the table of Bob's replies:
let R be the regexp entry;
if the topic understood matches the regular expression R:
say "[reply entry][paragraph break]" instead;
say "Eh, I dunno anything about no '[topic understood]'." instead.
Table of Bob's replies
regexp (indexed text) reply
"^(<Bb>ob|him(self)?)$" "Yeah, that's me, Bob."
"^((the|a)\s+)?((money|debts?|delay(ed)?|payments?)\s*)+$" "Look, I'll pay you as soon I can, you know that!"
As for your original problem, the real cause is Inform interpreting a plain “ask” as an incomplete version of the “ask [somebody] for [something]” command, rather than of “ask [somebody] about [text]”. The simplest solution might be to just tell Inform to understand those as mistakes instead:
Understand "ask" as a mistake ("Who do you want to ask about what?").
Understand "ask [person]" as a mistake ("Try asking [the noun] about something specific.").
Test me with "ask / ask bob / ask bob about bob / ask bob about money / ask bob about the delayed payment / ask bob about xyzzy".
Always be wary of question marks in your parser error messages. The player may read this and type “BOB”, or even “BOB ABOUT THE ROCK”.
I should note that in a finished IF game, there often won’t be a room with zero objects in it. (Other than Bob and the player – but objects the player is carrying do count.) So this kind of over-eager disambiguation is less of a problem than you might think. Obviously your very first I7 test code is a room with one thing in it, so newcomers ask this question quite a bit, but it’s really not something that I worry about at all.
That regexp table solution works perfectly. I generalized it so that every person has a table name called reply table.