How To Use Cycling Links

Wednesday, 5 July 2017 08:00 pm
giangtranguyen: (Default)
[personal profile] giangtranguyen posting in [community profile] twine_tutorials
Just copy and paste the code into the passage, then adjust it to your liking.

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;
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

Twine Tutorials

April 2018

S M T W T F S
1234567
8910111213 14
15161718192021
22232425262728
2930     

Style Credit

Expand Cut Tags

No cut tags
Page generated Sunday, 29 June 2025 11:33 pm
Powered by Dreamwidth Studios