First some background. I’m working on a piece (that will probably never come to light but is fun to write anyway) where there are changing lipogrammatic constraints. Different letters can be declared forbidden and as long as they remain forbidden, they won’t appear in the output. Of course, this means that I’m writing dozens of alternate versions of every piece of text that will be written to the screen. (Yes, this is an enormous amount of work, but fortunately writing the alternate versions of the text is the fun part for me, so I don’t mind.) I’ve got the necessary framework set up to do this (basically, I just end up writing tables of alternates in decreasing order of preference). But I would like to use some substitutions to make the process just a smidgen easier.
In particular, I would like to have a construct similar to the many variations of [one of] that are available where I can list a few versions of a piece of text and have it evaluate to the first version that fits the current constraint. Ideally, I would like to write something like “You [one of]take[or]get[or]pick up[as permitted] [the noun].” It would determine the first of the three options that is “permitted”, as defined elsewhere in the code (see below), choosing the last alternative if none of the options is permitted.
Near as I can tell, the only way to do something like this is to use segmented substitutions and Inform 6, roughly as described in section 27.30 of the documentation. I feel like I’ve got enough of a feel for how that’s supposed to work to do something that chooses a variation based solely on the position of the options (e.g., “under circumstance X, choose option number N”), but I need to actually work with the content of each option (e.g., “for each option N, if the text of that option satisfies property P, choose it, otherwise, move on to option N+1”).
Given that my I6 skills are pretty weak, how hard/complex would something like this be? Is there a better/simpler/more-I7 way to do it?
The exact code I’m using to determine whether text is “permitted” is probably irrelevant, but here it is:
[code]The list of forbidden letters is a list of text that varies.
To decide whether (X - some text) is forbidden:
repeat with L running through the list of forbidden letters:
if the substituted form of X matches the text L, case insensitively:
yes;
no.
To decide whether (X - some text) is permitted:
if X is forbidden, no;
yes.
To forbid (X - some text):
add X to the list of forbidden letters.
To permit (X - some text):
remove X from the list of forbidden letters, if present.
[/code]