Please specify version and format if asking for help, or apply optional tags above:
Twine Version: Twine 2
Story Format: SugarCube 2
Hello,
I’m totally new to Twine/SugarCube I was able to code everything on my own so far but it was only simple stuff and I admit I don’t quite understand how to do what I want with this one.
So what I want to do is use <<toggleLink >>
on the links inside the Table of Links code. (If HiEv happens to see this, thank you so much for your sample code !!)
Their code:
<<nobr>>
<<set $inv = []>>
/* Get the list of story passages' names. */
<<set _passages = Story.lookupWith(function () { return true; })>>
<<for _tmp range _passages>>
<<if _tmp.hasOwnProperty("title")>>
/* Skip passages with these tags. */
<<if !tags(_tmp.title).includesAny("Unlisted", "non-story-passage")>>
<<set $inv.push(_tmp.title)>>
<</if>>
<</if>>
<</for>>
<<set $inv = $inv.sort()>>
<<if $inv.indexOf("Main Menu") > 0>>
/* Make "Main Menu" the first link */
<<set _tmp = $inv.deleteAt($inv.indexOf("Main Menu"))>>
<<set $inv.unshift(_tmp)>>
<</if>>
<<set _tmp = "">>
<table width="100%">
/* Make three columns in our table. */
<col width="33%"><col width="33%"><col width="33%">
/* Put each element of the array in its own cell in the table. */
<<for _i = 0; _i < $inv.length; _i++>>
<<if $inv[_i] == "Main Menu">>
/* Bold "Main Menu" link */
<<set _tmp += "<td>''[" + "[" + $inv[_i] + "]]''</td>">>
<<else>>
/* Uses "[" + "[" to prevent Twine from creating a link. */
<<set _tmp += "<td>[" + "[" + $inv[_i] + "]]</td>">>
<</if>>
<<if _i % 3 == 2>>
/* Print out a table row. */
<<print "<tr>" + _tmp + "</tr>">>
<<set _tmp = "">>
<</if>>
<</for>>
/* Print any remaining cells. */
<<if _tmp != "">>
<<print "<tr>" + _tmp + "</tr>">>
<</if>>
</table>
<</nobr>>
I would also like to control the order in which the links are displayed and change their color with <span>
but I’m not sure how to do this either…
Thank you in advance !