Runtime Replacements ("Macros")

Based on a comment in another thread, I wrote an extension to allow players to use “macros” in their commands. For example:

That's not a verb I recognize.

>def v = inventory
[Text substitution defined: "v" => "inventory"]

You are carrying nothing.

See the extension documentation for a more complete example.

It currently allows both “simple” (word-level) replacements, like ‘v’ => ‘inventory’, and regular expressions, like ‘rezrov (.+)’ => ‘unlock \1 with autokey then open \1’. The performance hit only depends on the macros you’re currently using, so it’s almost nonexistent (checking that 32 table entries are empty) if no redefinitions are in use.

Do people think this would be nice to have, as a player? And what would make it better?

I can’t try it right now, but just reading through the code, wouldn’t the macro get substituted in the command trying to undefine it, and thus prevent the undefinition from working?

I do like the idea. Referring to the other thread, I too found that “look through oculus” became annoying after a while. I don’t know that this sort of functionality is properly the responsibility of the story, but on the other hand, it never really got picked up in interpreters. I don’t know that it would be useful in very many stories though.

facepalm yes. Let me fix that.

There, should be better now.


Not for every game, but occasionally there are games that just have you type long sequences that you’d really rather do without.

I would, say, love a shortcut for “consult ITEM about”. Or “ask NPC about” (there’s already some extension work for the latter, so you can use “a”, and it does alleviate). I’d love to, for example, shorten “consult volume about vampires” to “cva vampires”.