Associating text to pairs of things

I have a category of objects called quips which represent thoughts. In my previous thought-based games, I allow ‘linking’ thoughts by handwriting very long if/otherwise if statements.

For my upcoming Spring Thing Sherlock Holmes game, I’d like to simplify this by just associating text to pairs of things.

I assume I can’t write something like “a quip and a quip have some text”. I’ve thought about creating a table; however, most entries would be blank, so I believe it would be faster to automate its creation than to hand-roll it.

Is there a way to repeat through a list of items, creating one row for each quip and one column for each quip, and then populating them with a default message that I then override in a few specific instances?

What you’re asking for is a three-way or ternary relation, which isn’t currently allowed in Inform (because a newbie could easily create a ternary relation between objects and numbers and take up ridiculous amounts of space).

What I’d recommend is making a table like this:

Table of Paired Quips first second text …

Then check if the first and second quips are listed in the table, and if not, show the generic response.

As far as I know you can’t automatically create the right number of rows, but if you take care of that problem, you can easily do a loop within a loop to generate the table. There’s surely something like this in the source code for Terminator to initialize the Table of Planetary Surface, but I can’t find it right now. [EDIT: Actually there isn’t, I just did some math to figure out what the values in each row had to be.]

I ended up creating a different solution before checking intfiction.

I realized that doors were sort of ternary objects. So I created a new class of objects like “doors” between quips.

I made a new relation called connecting and put a quip door between every pair of objects that I had custom text for. Whenever I link two things, if there is a door between them, I print the description of that door.

(I don’t use actual doors, it’s just inspired by doors).