Howdy, Stranger!

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

Cyclinglinks - what am I doing wrong!?

In Twine1 - SugarCube2

I tried a cyclinglink test using 2 passages. One, called 'cl' containing -
<<cyclinglink "$test" "yes" "no" "maybe">>

[[well?]]

<<print $test>> here
<<set "$test" is "maybe">>

And the other 'well?' containing -
<<if "$test" is "yes">>Yes<<elseif "$test" is "no">>No<<elseif "$test" is "maybe">>Maybe<<else>>:(<<endif>>
What have I done wrong here?

Comments

  • Sorry, I should have mentioned; the script passage* should be OK as I ripped it from a source that TME had edited. For some reason I can't find that page now though.

    It's titled 'cyclinglink' and tagged 'script'.

    Inside is this -
    version.extensions.cyclinglinkMacro={major:3,minor:3,revision:0};
    macros.cyclinglink={handler:function(a,b,c){var rl="cyclingLink";
    function toggleText(w){w.classList.remove("cyclingLinkInit");
    w.classList.toggle(rl+"Enabled");w.classList.toggle(rl+"Disabled");
    w.style.display=((w.style.display=="none")?"inline":"none")}switch(c[c.length-1]){case"end":var end=true;
    c.pop();break;case"out":var out=true;c.pop();break}var v="";if(c.length&&c[0][0]=="$"){v=c[0].slice(1);
    c.shift()}var h=state.history[0].variables;if(out&&h[v]===""){return
    }var l=Wikifier.createInternalLink(a,null);l.className="internalLink cyclingLink";
    l.setAttribute("data-cycle",0);for(var i=0;i<c.length;i++){var on=(i==Math.max(c.indexOf(h[v]),0));
    var d=insertElement(null,"span",null,"cyclingLinkInit cyclingLink"+((on)?"En":"Dis")+"abled");
    if(on){h[v]=c[i];l.setAttribute("data-cycle",i)}else{d.style.display="none"
    }insertText(d,c[i]);if(on&&end&&i==c.length-1){l.parentNode.replaceChild(d,l)
    }else{l.appendChild(d)}}l.onclick=function(){var t=this.childNodes;
    var u=this.getAttribute("data-cycle")-0;var m=t.length;toggleText(t[u]);
    u=(u+1);if(!(out&&u==m)){u%=m;if(v){h[v]=c[u]}}else{h[v]=""}if((end||out)&&u==m-(end?1:0)){if(end){var n=this.removeChild(t[u]);
    n.className=rl+"End";n.style.display="inline";this.parentNode.replaceChild(n,this)
    }else{this.parentNode.removeChild(this);return}return}toggleText(t[u]);
    this.setAttribute("data-cycle",u)}}};
    

    Which I don't expect you to go through but somebody else might want it. :)
  • I also should have mentioned the effect I'm getting come to think of it. Which with this test I just get the :( but elsewhere I get that the first time and then if I click back a page and try again, each time I get the result corresponding to the previous choice.
  • I don't know where you got that, however, that is not SugarCube compatible.

    You need to get the version of <<cyclinglink>> from SugarCube v2's website.
  • Ah, I found it. This is where I got it originally -
    http://ludusnovus.net/2013/11/18/cyclinglinks-in-twine-sugarcube/
    
    Thanks TME, I'll see if I can find it there.
  • I couldn't find that but I'm sure it's there so I'll click this as answered. I've found another way that I'm happy with so no problem anyway. Ta!
  • edited May 2017
    ffs wrote: »
    I couldn't find that but I'm sure it's there […]
    It's on SugarCube v2's website, as I said. Specifically, under the Downloads > Add-ons section, listed as <<cyclinglink>> macro.
  • Aaah haaah, thanks for that! :)
Sign In or Register to comment.