0 votes
by (560 points)
Hi :)

I'm trying to create a simple image overlay character customisation (thank you so much for the advice TheMadExile! https://twinery.org/questions/962/how-can-we-layer-images-in-sugarcube-2-18). I'd just like to know how to save the state of a toggle choice for future passages so that the created avatar will appear?

Thanks a lot!

1 Answer

+1 vote
by (159k points)
selected by
Best answer

You can use a story variables to track the current state of each of your toggles.

1. Initialise the story variables within your projects StoryInit special passage.

note: I'm not sure if your toggles start out as displaying the content or not so I will assure that they do and assign the variable an initial value of true, if they don't then change the initial value to be false.

<<set $background to true>>

2. You can then change your toggle links to flip the associated story variable between true and false whenever they are selected.

<<click "Toggle: Background">>
	<<script>>$('#scene .layer0').toggle()<</script>>
	<<set $background to not $background>>


by (560 points)
That's fantastic, thanks so much for your help greyelf!