Consider
<<set $options to $room[$current].options>>
<<set $ix to 0>>
<<set $opt to $options[$ix]>
[[<<opt.choice>>|$options[$ix].goto][$score += $options[$ix].points]]
<<set $ix += 1>>
<<set $opt to $options[$ix]>
[[<<opt.choice>>|$options[$ix].goto][$score += $options[$ix].points]]
<<set $ix += 1>>
<<set $opt to $options[$ix]>
[[<<opt.choice>>|$options[$ix].goto][$score += $options[$ix].points]]
This code will print out three options. Only problem is that they won't work. The options will display properly, but when the link is clicked the destination and score increment used will be those of the last choice, not those for the choice the user selected.
Why? Well, both $options and $ix get updated with each iteration of the 'flattened' loop, so by the time the final option has been printed they have the values for it (the last line). The values in the destination and the tail seem not to be resolved until the link is clicked, at which point the variables have the wrong values.
That is to say, it seems to be storing:
[[Option A|$options[$ix].goto][$score += $options[$ix].points]]
...for it to work, it actually needs to store:
[[Option A|$options[1].goto][$score += $options[1].points]]
...or even...
[[Option A|Opt1_dest][$score += 5]]
Should I write up an issue for it?
Comments