Need help / toggleLink inside a table of links

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 :sweat_smile: 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 !

I would have a look at HiEv’s multicoloured links code for a basic understanding. If you want to generate links of certain colour for certain passages that might be beyond me at the moment. You’ll also need an array sorting method I think.
Array Sort method here

I hope that at least gets you started.

Hi, thanks for your reply but like I said, I don’t know how to do it inside that code.

I already know about the colors, I just don’t know where I could had that AND the toogleLinks code AND control the order of my links inside the Table of Links code…