There’s lots and lots and lots of ways to do that. It would be best if you specified how you want to look to the players of your game, rather than using pseudocode, since that gives us a clearer idea of what you actually want.
I’d also recommend at least skimming through the SugarCube documentation, that way you can get an idea of what kinds of options are available to you, and you can then later go back and read in detail as needed.
To answer your question, for one example, you might want have the player pick options from a dropdown list using the <<listbox>>
macro, which would then set a story variable (a variable with a name that starts with a “$
”). Then you can simply use an <<if>>
macro to determine what is displayed based on the value of that story variable. For example:
<label for="listbox-gender">''Gender:''</label>
<<listbox "$gender">>
<<option "Male" selected>>
<<option "Female">>
<<option "Non-binary">>
<</listbox>>
That would let the player select a gender from those three options, with “Male” as the default, and the result would be stored in the $gender story variable. (Note: The “for” attribute in the <label>
element should be in the form of “listbox-
(story variable name used in the <<listbox>>
macro without the “$
”)” or, for temporary variables, basically the same, except there should be two dashes after “listbox
” and the “_
” should be dropped from the variable name.)
Needless to say, that’s just one of many ways to do that. Using <<radiobutton>>
macros might be a better idea in cases where it’s only a couple of options and you want all options to be visible at once. Just make sure you set one to be checked by default. Take a look at the documentation for other options.
Later on you could then do:
<<if $gender == "Male">>\
Male text goes here.
<<elseif $gender == "Female">>\
Female text goes here.
<<else>>\
Non-binary text goes here.
<</if>>
Note: The “\
” characters prevent unnecessary line breaks, while keeping the code easy to read.
If you don’t want to put all of the text that needs to be displayed within a single passage like that, then instead of using a <<goto>>
macro, which will break passage navigation if used automatically within a passage (since it prevents the “back” button from working), it’s better to simply use an <<include>>
macro, which allows you to display the contents of one passage within a different passage.
Hopefully that all makes sense, but please ask if you have any questions. 