Hi I am a beginner, I’ve watched a few videos and referenced to forums but my variable value which the reader chooses at the beginning passage will revert to zero in other passages. I wonder why is that the case?
Twine Version: 2.5.1 (website)
Story Format: Harlowe
To give some context, I’m making an rpg with selectable character settings which I would like to appear on other passages as well.
The beginning passage, titled Welcome contains this code:
Character Creation: (text-colour: blue)[$name]
Gender: (text-colour: blue)[(set: $gender to (array: "male", "female","non-binary"))(set: $g to 1)|gender>[(print: $gender's ($g))] (display: "gender")]
Hair length: (text-colour: blue)[(set: $hair_length to (array: "long", "short", "medium"))(set: $hl to 1)|hair_length>[(print: $hair_length's ($hl))] (display: "hair length")] Hair colour: (text-colour: blue)[(set: $hair_colour to (array: "black", "brown", "blonde","platinum","auburn","pink","red","lilac","indigo","white","grey","silver","green","midnight blue","pale blue"))(set: $hc to 1)|hair_colour>[(print: $hair_colour's ($hc))] (display: "hair colour")]
Eye colour: (text-colour: blue)[(set: $eye_colour to (array: "black", "brown", "gold","red","purple"," blue","silver","grey","green","amber","pink"))(set: $eye to 1)|eye_colour>[(print: $eye_colour's ($eye))] (display: "eye colour")]
Skin tone: (text-colour: blue)[(set: $skin_tone to (array: "fair", "beige", "tanned","golden","olive","sepia"))(set: $skin to 1)|skin_tone>[(print: $skin_tone's ($skin))] (display: "skin")]
Height: (text-colour: blue)[(set: $height to (array: "average","tall","short"))(set: $h to 1)|height>[(print: $height's ($h))] (display: "height")]
Select where you'd like to be transported to:
[[School of Magic->School Prologue]]
[[Medieval World->Medieval Prologue]]
[[Survival Novel->Survival Prologue]]
The unlinked passage contains this code, because I wanted readers to choose which gender, hair colour, eye colour, etc, by toggling between the options:
(link-repeat: "> ")[{
(if: $g is $gender's length)[(set: $g to 1)]
(else:)[(set: $g to $g + 1)]
(replace: ?gender)[(print: $gender's ($g))]
}]
Then when I (print: $gender) on another passage, it just shows zero.
I hope a kind soul can advise me on how to write a code that fixes the value that the reader chose throughout entire story’s variables. Thank you!