Happy to help!
I noticed some artifacts in the output when using UNDO with the above code. Replacing the OrderThing stub with this code should fix it:
includeInUndo = nil
actionTime = 0
That way the extra action doesn't count against the player's time, and undo will skip over it.
Jim Aikin wrote:
Please correct me if I'm wrong, but my impression is that Ben Cressey's code for DefineLiteralAction will work correctly for 'order sandwich' but will fail if the player types 'order a sandwich'. The advantage of using Topic objects, I'm pretty sure, is that things like articles and adjectives can be understood and handled.
The simple switch statement in the execAction can be replaced with string methods to do more sophisticated matching. Also, the VerbRule can be expanded to handle articles, so you don't have to worry about them when processing the literal.
'order' | ('order' ('a' | 'the' | 'an' | 'some' )) singleLiteral
verbPhrase = 'order/ordering (what)'
You're right that this approach is not a good general practice. The alternative approach I came up with - an invisible actor who comes into scope during Order actions, and responds to topics by executing some code - strikes me as too convoluted, though it would leverage the parser rather than doing an end-run around it.