I think this would basically amount to creating an action on text that matched a “[text]” token, and then having our spell check whether the topic understood matched the magic word:
[code]Test Chamber is a room.
The magic word is a text that varies.
When play begins:
now the magic word is the substituted form of “[one of]xyzzy[or]plugh[or]plover[or]frotzle[or]frobnoid[purely at random]”.
The player carries the book. The description of the book is “It falls open to a page that says ‘[the magic word]’ in ornate gold letters.”
Performing magic is an action applying to one topic.
Understand “[text]” as performing magic.
Check performing magic (this is the failed spells are unrecognized rule):
unless “[the topic understood]” matches the text “[the magic word]”:
say “[text of parser error internal rule response (N)][line break]” instead. [this is just “not a verb I recogniz/se”]
To intone is a verb.
Report performing magic (this is the report performing magic rule):
say “[We] [intone] the word ‘[the magic word]’ in a commanding voice, and [our] eyebrows grow bushier.” (A).
Test me with “read book / read book / read book / xyzzy / plugh / plover / frotzle / frobnoid”.[/code]
It took an annoying amount of fiddling before I hit on ‘unless “[the topic understood]” matches the text “[the magic word]”:’ as the formulation for that line. Is there a more direct way?
We could also create the possible magic words as a value and have our action run on that:
[code]Test Chamber is a room.
A spell is a kind of value. The spells are xyzzy, plugh, plover, frotzle, and frobnoid.
The magic word is a spell that varies.
When play begins:
now the magic word is a random spell.
The player carries the book. The description of the book is “It falls open to a page that says ‘[the magic word]’ in ornate gold letters.”
Performing magic is an action applying to one spell.
[Can we avoid enumerating these?]
Understand “[spell]” as performing magic.
Check performing magic (this is the spell must be the magic word rule):
unless the spell understood is the magic word:
say “You sense a distant disturbance, as if the spell you uttered had some effect in an alternate universe; but in this universe, nothing happens.” instead.
To intone is a verb.
Report performing magic (this is the report performing magic rule):
say “[We] [intone] the word ‘[the magic word]’ in a commanding voice, and [our] eyebrows grow bushier.” (A).
Test me with “read book / read book / read book / xyzzy / plugh / plover / frotzle / frobnoid”.[/code]
(I didn’t make the text of my check performing magic rule adaptive, due to laziness.) This lets us write custom responses to the other possible magic words and may avoid some complications from an unrestricted “[text]” token.
I’d have liked to try this:
Understand "[spell]" as performing magic when the spell understood is the magic word.
but the “understand” line doesn’t work even when you use the magic word. I guess that “the spell understood” probably isn’t set at that stage of parsing. (You can write things like “…when the item described is the magic item” when doing an action on things, at least I think you can, but I’m not sure if you can do this for non-object kinds of value. Not sure how the internals work.)