Help with making buttons that expand text in a passage

I’m trying to make buttons that expand new information to the player without going into an entirely new passage. I’d also like for when there’s multiple buttons, whichever button the player picks disappears alongside the chosen button.

<<button "What's going on?">>																					

	<<goto [[What happened to me? | Ch 1 Pg 3]]>>

<</button>>

<<button "No, let's start.">>

	<<goto [[No, let's start | Ch 1 Pg 4]]>>
    
<</button>>

Sorry about all the questions today. I’ve been stuck trying to figure this out and going back to older forums.

You can use the <<replace>> macro: SugarCube v2 Documentation

I’m not really sure if you want all the buttons to disappear when you choose one of them, or only one, so I’ll cover both cases. In this example, only the selected button will disappear and replace itself with text:

<span id = "button1">
<<button "Button1">><<replace #button1>>Some text<</replace>><</button>>
</span>

<span id = "button2">
<<button "Button2">><<replace #button2>>Other text<</replace>><</button>>
</span>

And in this example, both buttons disappear when you click any of them:

<span id = "buttons">
<<button "Button1">><<replace #buttons>>Some text<</replace>><</button>>

<<button "Button2">><<replace #buttons>>Other text<</replace>><</button>>
</span>
3 Likes

This works! Thanks for the help.

1 Like