Hi there,
I'm currently using
Furkle Industries's "Cycling Links" script for the Harlowe template, but I'm running into two problems I don't know how to fix.
First of all, when I test-play, the variable affected by the cycling link is highlighted in yellow - as demonstrated below.
The point of the link shown above is to change a variable, $voicemailSeconds in this case, which in the story determines the length of a voicemail message. Clicking the "transcript" link takes you to a page where, depending on the variable, a different transcript of a different message is printed. Easy enough.
I've added a custom return button on the page, and when you press back, the value for the variable is still the one that was last picked. However, when clicking it again, it doesn't go to the next value after that in the list. It starts cycling from the first value in the list again. Ideally, you should be able to click back to the previous page, click the cycling link, change the variable and then read a new transcript.
This is the code for the cycling link:
<mark><tw-link class='cyclingLink' data-cycling-texts='["5", "9", "11", "17", "18", "20", "21", "25", "42", "180"]'
onclick='clickCyclingLink(this,"$voicemailSeconds");'>$voicemailSeconds</tw-link></mark>
That means, if you leave the page on the variable with value 17, you will return to the page and the variable will still be at 17. After clicking it again, I want the variable to go to 18. But instead it starts back at 5. I could probably work around it and add conditions to the page (if variable = x, start the order in a different place), but there must be a more elegant and simpler way.
Comments
I want the player to be able to cycle through 3 options that will toggle the visibility for three links.
I understand THIS part:
(set: $var to "1")<tw-link class='cyclingLink' data-cycling-texts='["1", "2", "3"]' onclick='clickCyclingLink(this, "$var");'>$var</tw-link>
Now I need to make this work:
(if $var = 1)(display:link1->link1)
Could just be that I'm not understanding correctly how that macro operates because I'm so new at this. Any help appreciated.
Thanks!
(Still in Harlowe.)
There are a number of errors in your (if:) macro example:
1. The example is first assigning the value of 1 to the $var variable and then testing if the assignment was true.
2. It is missing the colon after the if keyword and the square brackets of the associated hook.
3. The (display:) macro shows the contents of one passage within another, you are trying to make it show a markup link.
The following demonstrates the usage of the to and is keywords and how to conditionally show a markup link.
No matter what I alter, all 3 links appear at all times instead of one at a time.
I'm wondering if the trouble is because my variable is set to strings instead of singular numeric values?
This is what it looks like right now:
The (if:$asian is "jar of furikake") statement in your example is process only once, at the time the passages is rendered and at that time the $asian variable has a value of "jar of furikake" (due to the preceding (set:) macro).
Changing the value of a $variable does not cause statements (like the (if:) macro) based on that variable to be re-processed.
You can do what you want by moving the (if:) macro into an intermediate passage and then based on the value of $asian have is (display:) the correct description.
The following example is made up of five passages:
a. Start b. Explain Item c. Three passages (named Furikake, Kimchi, and Hundred-Year Egg) containing the actual item descriptions.
Am I understanding that correctly?
OR
I can get two error messages: "There's nothing before this to do (else-if:) with." and "There's nothing before this to do (else:) with." That's when it looks like
^That structure parallels (as far as I can see) the if, if else, else macro structure in your answer here: http://twinery.org/forum/discussion/2988/complex-ruleset-problems-in-harlowe
note: When you use Harlowe's Undo button to return to the Start passage from the passage showing the item description the value of $asian is reset back to "jar of furikake". This has nothing to do with my example, it is just how undo'ing History works.
Now it's working perfectly-- thanks so much for your help.