Hello! I am using Twine 2 on the website version and Sugarcube 2.36.1.
There seems to be a problem when I code an if statement. I start with the radiobutton choices first.
<<if $prn is "She">>
<<set $prna to 'she'>>
<<set $prnb to 'her'>>
<<set $prnc to 'hers'>>
<<elseif $prn is "He">>
<<set $prna to 'he'>>
<<set $prnb to 'him'>>
<<set $prnc to 'his'>>
<<elseif $prn is "They">>
<<set $prna to 'they'>>
<<set $prnb to 'them'>>
<<set $prnc to 'theirs'>>
<</if>>
However, when I choose They/Them or He/Him, it prints “she/her/hers” instead. Is there anything wrong with my coding?
Hi!
I can’t find any issues within the code you posted. Where are you checking/printing the resulting variables? If it’s in the same passage that has the radiobuttons, the printed values won’t update when you change your selection - they only change upon the passage transition (unless you use replace).
Is the sequence of <<if>> macro calls within the same Passage as the <<radiobutton>> macro calls?
If they are then you will need to delay the execution of the <<if>> macro calls, otherwise they will be executed before the end-user has had a chance to interact with the radio buttons. And changing the value of a variable does not cause the automatic re-execution of any code that makes reference to that variable.
One method you can use to delay the execution of code is you place it within a <<link>> or <<button>>…
<<link "Update Pronouns">>
<<if $prn is "She">>
<<set $prna to 'she'>>
<<set $prnb to 'her'>>
<<set $prnc to 'hers'>>
<<elseif $prn is "He">>
<<set $prna to 'he'>>
<<set $prnb to 'him'>>
<<set $prnc to 'his'>>
<<elseif $prn is "They">>
<<set $prna to 'they'>>
<<set $prnb to 'them'>>
<<set $prnc to 'theirs'>>
<</if>>
<</link>>
Nope, they were both in different passages. I entered the if statement after the passage that contained the radiobutton. I have no idea why it does that