Using <<radiobutton>> to set a passage link?

Twine Version: 2.3.14
Story Format: SugarCube 2.34.1
Short answers of ‘No, not possible’ are perfectly fine.

Using the example from the <> SugarCube v2 Documentation: Is it possible to create a link to a passage name from the value of $pie?

What's your favorite pie?
* <label><<radiobutton "$pie" "blueberry" checked>> Blueberry?</label>
* <label><<radiobutton "$pie" "cherry">> Cherry?</label>
* <label><<radiobutton "$pie" "coconut cream">> Coconut cream?</label>

[[Continue|$pie]]

If the player selects Blueberry, I want to send them to a passage named blueberry, etc. (I know about the wonky creation of passages when using a variable in a link and I delete the $pie passage that gets created.)

I’ve dug through the documentation and tried various things but for the life of me I cannot get it to work. The radiobutttons appear. I can select them but I never get sent anywhere other than to the initial ‘checked’ value. Debug modes shows the value of $pie is set as whatever I set to ‘checked’ and that value never changes no matter what other radio button I select. I’ve tried $StoryVariables and _TemporaryVariables. I am at a loss. I feel like I may be missing something super obvious.

1 Like

The link text and destination passage are processed immediately, rather than when activated by the player, which is what you need in this case.

This is one of the very few instances where you want to use the <<goto>> macro, within a <<link>>, so you can shift when the destination is processed. For example:

<<link "Continue">><<goto $pie>><</link>>

If the passage variable doesn’t need to live beyond that, I’d definitely suggest using a temporary variable.

PS: If you’ll ever be doing something like this and reusing the variable, you’ll want to wrap that in <<capture>>.

1 Like

This is perfect! Thank you!