SugarCube cycle macro default option from list

Twine Version: 2.3.9 (online)
Story Format: SugarCube 2.33.0

When it comes to customizing the characters (player and some NPCs), I have variable lists that provide the choices. For example, when it comes to hair color, the same list is then presented:

<<set $haircolors to [
	"strawberry blonde",

When it comes time to setup the player and the customizable NPCs. I use the cycle macro as follows:

....they have shoulder length <<cycle "_npchc" autoselect>><<optionsfrom $haircolors>><</cycle>> hair...

Further down, ‘_npchc’ is mapped to the correct NPC being configured with the rest of their setup. This part all works nicely, except I can’t figure out how to have it select default values. Each of my NPCs has a default look, that the user can change if they want.

The SugarCube2 documentation shows that when using ‘option’ you can use ‘selected:’ to have it use that as the default. Which would be exactly what I want. However, I was hoping to use the list because it gives me one place to manage things and not currently 3 (will climb to 10) especially once I add in hair, eyes, skin tones, etc…

Is there a way I can use a list like above, ensuring that the default profile for my NPCs can still be maintained?


I’d read the description of autoselect again, because it does what you want if you initially set the receiver variable to the appropriate default value.

For example:

<<set _npchc to "blonde">>
<<cycle "_npchc" autoselect>><<optionsfrom $haircolors>><</cycle>> hair...
1 Like

That is my lack of coding experience kicking in there.

I was trying to use the autoselect and selected in the syntax, which would explain why it wasn’t working.

That works perfectly. And I get what it’s doing now.