Created
February 14, 2014 22:38
-
-
Save sophiathekitty/9010907 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//requires jquery | |
macros['displaylink'] = { | |
handler: function(html,name,args,wikifier){ | |
if(args.length > 0){ | |
var p = ""; | |
var n = ""; | |
if(args.length == 1){ | |
if(tale.has(args[0])) | |
p = args[0]; | |
n = p; | |
} else { | |
if(tale.has(args[0])){ | |
p = args[0]; | |
n = args[1] | |
} else { | |
p = args[1]; | |
n = args[0]; | |
} | |
} | |
if(tale.has(p)){ | |
console.log(html); | |
new Wikifier(html, "<span class='displaylink'><a href='#' passage='"+p+"' onclick='showLinkPassage(this)' class='displaylink_link'>"+n+"</a><span style='display:none;'></span></span>"); | |
} | |
window.showLinkPassage = function(obj){ | |
$(obj).hide(); | |
var t = tale.get($(obj).attr("passage")); | |
new Wikifier($($(obj).next())[0], t.processText()); | |
$(obj).next().show(); | |
} | |
} | |
} | |
} |
copy the script into a twine script.
to use with your story use the custom macros
<<displaylink "Passage Title">>
<<displaylink "link text" "Passage Title">>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
script for twine. creates a link that is replaced by a passage when clicked.