I’m rewriting my EctoComp entry, Super Halloween Horror Show, in Dialog, partly as a learning exercise and partly because, as a limited-parser game, I think it would work really well with the kind of hybrid interface that Dialog excels at. Most of the translation has been pretty straightforward, but I’ve run into an issue that I can’t figure out how to debug.
The majority of interaction in SHHS involves showing things to NPCs, most often your emotions (which appear as objects in your inventory). Because your emotions come and go over the course of play, it’s pretty common for the player to try to show an emotion that they no longer have, and I wanted this to give a more illuminating message than “you can’t see any such thing.”
In Inform 7, I accomplished this as follows:
Understand "show [any emotion] to [someone]" as showing it to.
The access through barriers rule response (A) is "You aren't feeling that emotion right now.".
The key being the [any emotion] token, which means the game recognises the name of an emotion as the noun for SHOW whether or not it’s in scope.
Following the example in the Dialog manual, I have tried to get the same effect like this:
(grammar [show [emotion] to [animate]] for [show $ to $])
(grammar [show [animate] [emotion]] for [show $ to $] reversed)
(grammar [show [emotion]] for [show $])
@(grammar transformer [[emotion] | $Tail] $SoFar $Verb $Action $Rev)
(grammar transformer $Tail [90 | $SoFar] $Verb $Action $Rev)
(match grammar token 90 against $Words $ into $Obj)
*(understand $Words as any object $Obj)
(emotion $Obj)
(before [show $Emotion to $])
~($Emotion is #heldby #player)
You aren't feeling that emotion right now.
(This is in my main .dg file, included before the library. (emotion $) is a predicate which applies to all of the emotion objects. They’re not (item $), in case that’s relevant.)
Unfortunately, it doesn’t seem to work, since when I try to SHOW an NPC an emotion I’m not carrying, I get the generic “I only understood you as far as wanting to show something to the NPC” response, the same as if none of the above code were included. I don’t know how to dig any deeper into the workings of the parser here to determine why the code above isn’t working as it should. Any help?