I guess because it’s tedious to refer to / check table cells, and also more tedious for the author. This is for an extension, so I want to make the author-programmable parts of it as painless as possible.
OK, here’s more detail.
Below is a table that is illegal but shows what I’m after:
Table of cyoa-hardcoded key logic
option (a truth state) the keys (a list)
cyoa-allow quit cyoa-quit keys
cyoa-allow undo cyoa-undo keys
cyoa-support credits cyoa-credits keys
cyoa-support transcripting cyoa-transcript keys
cyoa-support saves cyoa-save keys
So I want to iterate through the rows.
If a truth state in the left column is true, I then want to iterate through the corresponding list of numbers in the right column.
One roundabout way to do this is to use a text substitution. You can store the text variable “[if allow quit is true]X” in a table column or variable, then check whether it evaluates to “X” (if the variable is true) or the empty string (if false). Depending on your needs you can also look at the approach I took in my Boolean Variables extension (which basically provides an easy ‘options’ menu for turning things on and off during play).
You can’t store a variable reference in a table at compile time, but you can at run time. So one option would be to build the table at run time. Another would be to use list literals in the table.
Is this for handling key presses? Another option entirely would be to do it all programmatically. Have you seen Kerkerkruip’s approach? You pass in the keycode as the argument to a number based rulebook. Rules which match the keycodes run, and can process their own logic. If you want to make the options disable-able, it wouldn’t be hard to check in those rules whether they’re enabled or not, and if they aren’t make no decision.
I don’t think I’m understanding. Here’s my test code.
Table of Temporary
X is initially 7.
Instead of jumping: increment X; say “Done.”.
Instead of waving hands:
say "X: [X] Val: ";
choose row 1 in the Table of Temporary;
say the val entry;
say line break;
now the val entry is X.
Test me with “wave / wave / jump / wave”.
Foo is a room.
Edit - Upon closer inspection of your example, I think what I say below doesn’t apply. But in case or FYI:
There’s been a change from Inform 6G60 to the new generation regarding the circumstances in which text substitutions fix their values, due to the fact that plain ol’ text and indexed text are now both just ‘text’.
It could be that you need to look into that change and the parameters around it to make the example work (you may need to set a preference or use a new particular phrase). Or it could be that Dannii’s recollection about how this can work is no longer true in the new Inform.