I wish the Harlowe documentation pages had all these ".length" ".toString" ".indexOf" type modifiers on them so I know they exist. It took me ages to figure out that "$example's 1" etc worked fine instead of having to use 1st the way the documentation says.
I'm not sure if that would help... I'll post the full code:
Passage "p1" :
{
(set: $ArrayAnswer to (words: "h e y"))
(set: $ArrayCurrent to (a:))
<!-- sets ArrayCurrent to ???s of appropriate length -->
(for: each _letter, ...$ArrayAnswer)[
(set: $ArrayCurrent to it + (a: "?"))
]
}
|displayer>[(display: "p2")]
<!-- displayed by p2 once complete -->
|end)[Congratulations!]
{
<!-- Working Version -->
(link: "1")[
(set: $ArrayCurrent's 1 to $ArrayAnswer's 1)
(replace: ?displayer)[(display: "p2")]
]
(link: "2")[
(set: $ArrayCurrent's 2 to $ArrayAnswer's 2)
(replace: ?displayer)[(display: "p2")]
]
(link: "3")[
(set: $ArrayCurrent's 3 to $ArrayAnswer's 3)
(replace: ?displayer)[(display: "p2")]
]
}
{
<!-- Not Working -->
(set: $x to 0)
(for: each _a, ...$ArrayAnswer)[
(set: $x to it+1)
(link: "$x")[
(set: $ArrayCurrent's $x to $ArrayAnswer's $x)
(replace: ?displayer)[(display: "p2")]
]
]
}
Passage "p2" :
{
(if: $ArrayCurrent is $ArrayAnswer)[
(show: ?end)
]
<!-- display current progress -->
(text: ...$ArrayCurrent)
}
The idea is to be able to set a word for the first array, and have the rest of the page generate based on how long that array is. If I manually set the links with the correct numbers, as shown above, then it works fine.
Below it I tried to make a for loop to generate the links, which works, but by the time the links are actually clicked, they're all set to the max number rather than their appropriate numbers. Even if I create an array full of integers, by the time the link code is processed, I can't think of any way to have the right values placed in each one.