I'm currently using furkle's
cycling link macro for Harlowe in Twine 2.0.11 and Harlowe 1.2.2 (on desktop). I have the below code in a passage:
<tw-link class = 'cyclingLink' data-cycling-texts='["Dark", "Red", "Blonde", "Light"]' onclick='clickCyclingLink(this, "$haircolour");'>$haircolour</tw-link> hair frames your face.
and there are two problems - first, when I test play it, $haircolour is initially set to 0 instead of "Dark". How can I get the variable to be set to the first item in the list? Second, I realised that when I click through the cycling link, $haircolour isn't set to a new variable each time, it just remains as 0. Any ideas how I might go about fixing this?
Comments
Second. At the risk of sounding like a jerk, reading the examples and documentation on the page you linked, or reading them better, probably would have helped you here. The example from that page shows how to initially set the value of your $variable and the Passage Usage section even explains why you must do so.
In other words, your code should look something like the following:
As to your $haircolour variable not being changed by the cycling link construct. How are you checking? If you're trying some static test on the same page, then that's never going to work as the construct is dynamic (i.e. it changes the value of $haircolour after the static page elements have been rendered). You'd need to either move to a new passage or use a dynamic check (e.g. using the (live:) macro).
I'm attaching a Twine 2 archive of a working demo.
*hides in hole*
I... probably should have realised that my checks weren't dynamic. (And so on.) Thanks so much!
If you don't want the cycling link to display the variable's current value, then simply don't use the cycling link code. You can cycle through a list easily enough with the built-ins.
For example, assume that you've done something like the following someplace earlier: A link which will cycle the array and assign its current 1st value to the given variable might look like the following: