How To Use Cycling Links
Wednesday, 5 July 2017 08:00 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
Just copy and paste the code into the passage, then adjust it to your liking.
For example:
Or
In order for it to work, you need to copy and paste the code into Story Javascript.
For example:
For example:
(set: $ThirdYears to "Third Years")
Hello <tw-link class='cyclingLink' data-cycling-texts='["Sawamura Daichi", "Sugawara Koushi", "Azumane Asahi"]' onclick='clickCyclingLink(this, "$ThirdYears");'>$ThirdYears</tw-link>.
(link: "I know who I want")[(goto: $ThirdYears)]
Or
(set: $ThirdYears to "Third Years")
Hello <tw-link class='cyclingLink' data-cycling-texts='["Sawamura Daichi", "Sugawara Koushi", "Azumane Asahi"]' onclick='clickCyclingLink(this, "$ThirdYears");'>$ThirdYears</tw-link>.
(link: "I know who I want")[{
(if: $ThirdYears is "Sawamura Daichi")[(goto: "First Passage")]
(elseif: $ThirdYears is "Sugawara Koushi")[(goto: "Second Passage")]
(else:)[(goto: "Third Passage")]}]
In order for it to work, you need to copy and paste the code into Story Javascript.
For example:
function clickCyclingLink(e,a){var t=JSON.parse($(e).attr("data-cycling-texts"));if(!("undefined"==typeof t||t.length<2)){t.push(t.shift());var i=t[0];if("$"===i[0])i=getHarloweVariable(i);else if("out"===i)$(e).remove();else if("end"===i){var n=t[t.length-1];t="$"===n[0]?[getHarloweVariable(n)]:[t[t.length-1]],$(e).hasClass("endedCyclingLink")||$(e).addClass("endedCyclingLink")}else if("goto "===i.slice(0,5)){var l=i.slice(5,i.length);"$"===l[0]&&(l=l.slice(1,l.length));var s=parseInt(l.trim());if(isNaN(s)){var r=$("tw-storydata > tw-passagedata[name="+l+"]");"undefined"!=typeof r&&r.length>=1&&_engine.goToPassage($(r).attr("pid"))}else{var r=$("tw-storydata > tw-passagedata[pid="+s+"]");"undefined"!=typeof r&&r.length>1&&_engine.goToPassage(s)}}setHarloweVariable(a,t[0]),$(e).text(i),$(e).attr("data-cycling-texts",JSON.stringify(t))}}function getHarloweVariable(e){return"undefined"!=typeof e&&""!==e?"$"===e[0]?_state.variables[e.slice(1,e.length)]:_state.variables[e]:void 0}function setHarloweVariable(e,a){"undefined"!=typeof e&&""!==e&&"undefined"!=typeof a&&("$"===e[0]&&(e=e.slice(1,e.length)),_state.variables[e]=a)}var _engine=Engine;window._engine=_engine;var _state=State;window._state=_state,window.clickCyclingLink=clickCyclingLink,window.getHarloweVariable=getHarloweVariable,window.setHarloweVariable=setHarloweVariable;
function getHarloweVariable(e){return"undefined"!=typeof e&&""!==e?"$"===e[0]?_state.variables[e.slice(1,e.length)]:_state.variables[e]:void 0}var _state=State;window._state=_state,window.getHarloweVariable=getHarloweVariable;
function setHarloweVariable(e,a){"undefined"!=typeof e&&""!==e&&"undefined"!=typeof a&&("$"===e[0]&&(e=e.slice(1,e.length)),_state.variables[e]=a)}var _state=State;window._state=_state,window.setHarloweVariable=setHarloweVariable;