Questionclass | parser.t[1065] |
Superclass Tree | Subclass Tree | Global Objects | Property Summary | Method Summary | Property Details | Method Details |
The parser uses Question objects internally to handle certain errors that the player can fix by entering additional information, such as disambiguation queries and missing noun phrase queries. Games can use Question objects for other, custom interactions.
The basic Question object is incomplete - you have to subclass it to get a functional question handler. In particular, you must provide a parseAnswer() routine that parses the reply and creates a Command to carry out the action of answering the question.
class
Question : object
Question
GramQuestion
YesNoQuestion
ParseErrorQuestion
RexQuestion
answerTemplate | parser.t[1110] |
priority | parser.t[1093] |
For disambiguation and missing noun queries, the parser only parses question replies AFTER parsing regular commands. Replies to these questions are frequently very short, abbreviated noun phrases - maybe just a single adjective or noun. It's fairly common for there be at least a few nouns that are the same as verbs in the game, so the input after a disambiguation or missing noun reply can often be interpreted equally well as a new verb or as a reply to the question. There's probably no theoretical basis for choosing one over the other when this happens, but in practice it seems that it's usually better to treat the reply as a new command. So, by default we set this property to nil, to give priority to a new command.
Custom questions posed by the game might want to give higher priority to the answer interpretation, though. Yes/No questions in particular will probably want to do this, because otherwise the parser would take the answer as a conversational overture to any nearby NPC.
parseAnswer (toks, dict) | parser.t[1107] |
If the input does look like a valid answer to the question, returns a CommandList with the parsed reply. If not, returns nil, in which case the parser will continue trying to parse the input as a whole new command.
By default, we simply return nil. Subclasses/instances must override this to provide the custom answer parsing.