Switch based dialog help Sugarcube 2.31.1

Coming back to twine after a hardy break and some more experience in other ventures, I was wondering why the ‘whats your name’ button won’t set my switch to ‘name’. it always comes back to the default case when it loops.

I’d like the dialog option to change the switch case to display a corresponding dialog. is what I’m doing possible and if so what and I doing wrong?

<<switch $captainQuestions>>\
<<case "name">>\
<<SeaCaptain>>Simon.<</SeaCaptain>>
<<default>>\
<<SeaCaptain>>Like what?<</SeaCaptain>>

<div class="btn-group">\
	<div class="container">
		<<button [[What's your name?|captain][$captainQuestions to "name"]]>><</button>>\
		<<button [[What's this boat normally used for?|captain]]>><</button>>\
		<<button [[Do you live in Drogg Harbor?|captain]]>><</button>>\
		<<button [[I had other questions.|Captain dialog]]>><</button>>
	</div>\
</div>
<</switch>>

Thanks!

From what I see you’re trying to use a markup link inside a button. I’m not sure it is possible. I’m not sure it isn’t neither, maybe someone more proficient with Sugarcube could tell.
However you can use a set https://www.motoslave.net/sugarcube/2/docs/#macros-macro-set macro inside a button macro.

Here’s how it might be done:

<<button [[What's your name?|captain]]>><<set $captainQuestions to "name">><</button>>
2 Likes

Souppilouliouma, is correct about the solution. I’ll just note that the SugarCube “Link” documentation says:

The Setter component, which only works with passage links, …

Thus that’s why the Setter you were using wasn’t triggering when used as a parameter of the <<button>> macro.

1 Like