Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Problems with cycling links in Harlowe

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.

4cOSt1Cl.png

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 do not know how to solve the highlight problem, but you could add a setter link that saves the time on a variable when changing passages, and then have it add to the clock.
  • Removing <mark> and </mark> removes the highlight.
  • I'm having trouble with the cycling links as well, but for a different reason.

    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.)
  • In Twine-script (and Javascript) a single equals sign '=' represents value assignment, where as a double equals sign '==' represents value comparison.

    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.
    (set: $var to 1)
    
    (if: $var is 1)[[[link1->link1]]]
    
  • You're exceptionally patient and helpful! Thank you very much.
  • The cyclin link works perfectly, but I'm still having trouble associating it with a conditional link even with your script corrections.

    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:
    She points. "What's that?"

    There's a (set: $asian to "jar of furikake")<tw-link class='cyclingLink' data-cycling-texts='["jar of furikake", "jar of kimchi", "dish of hundred-year eggs"]' onclick='clickCyclingLink(this, "$asian");'>$asian</tw-link> on the table.

    (if:$asian is "jar of furikake")Explain.->Furikake(if:$asian is "jar of kimchi")Explain.->Kimchi(if:$asian is "dish of hundred-year eggs")Explain.->Hundred-Year Egg
  • Your problem is one of timing.

    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
    She points. "What's that?"
    
    There's a (set: $asian to "jar of furikake")<tw-link class='cyclingLink' data-cycling-texts='["jar of furikake", "jar of kimchi", "dish of hundred-year eggs"]' onclick='clickCyclingLink(this, "$asian");'>$asian</tw-link> on the table.
    
    [[Explain.->Explain Item]]
    
    b. Explain Item
    (if: $asian is "jar of furikake")[(display: "Furikake")](else-if: $asian is "jar of kimchi")[(display: "Kimchi")](else-if: $asian is "dish of hundred-year eggs")[(display: "Hundred-Year Egg")](else:)[Unknown item.]
    
    c. Three passages (named Furikake, Kimchi, and Hundred-Year Egg) containing the actual item descriptions.
  • edited September 2015
    Ohhh I see. So, for $variable changes to be noticed by Twine, the passage needs to be reloaded/changed. So I need to ask it to test for a change in a separate passage, which will use (if:) macros to pull text from other passages (which, in my editor, will free float rather than being connected ---> to "Explain item" or "Start".

    Am I understanding that correctly?
  • That still displays only the text from passage "Furikake" even when the cycling link is toggled.
    (if:$asian is "jar of furikake")[(display: "Furikake")](else-if: $asian is "jar of kimchi")[(display:"Kimchi")](else:$asian is "dish of hundred-year eggs")[(display:"Hundred-Year Egg")]

    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
    (if:$asian is "jar of furikake")[(display: "Furikake")(else-if: $asian is "jar of kimchi")[(display:"Kimchi")(else:$asian is "dish of hundred-year eggs")[(display:"Hundred-Year Egg")]]]

    ^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
  • I have attached a working copy of my example.

    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.
  • So you did essentially what I did the first time. It doesn't look like the **value** of my variable is cycling at all--I'm still getting only the passage associated with the first/default option in the cycling link every time.
  • I got it. The trouble was not swapping out the defauly "twineVar" for the name of my variable in the javascript itself. I thought I had already done that, but it turns out there are two and I missed one.

    Now it's working perfectly-- thanks so much for your help.
Sign In or Register to comment.