Custom text based on what image selected

I have a character creation screen where you choose between 3 different characters, I would like it so that depending on what character they chose it would show different text, so far this is what I have for the images

[img[images/Waylight epe.jpg][Waylight Select][$r to 1]] [img[images/Voxiremise epe.jpg][Fallen Star Select][$r to 2]] [img[images/forgottenking.jpg][Forgotten Select][$r to 3]]

This is what I have written for the text

<<if $r is 1>> A floating lamp <</if>> <<if$r is 2>> A floating star <</if>> <<if$r is 3>> UNKNOWN <</if>>

From what I can tell it works perfectly fine, but I have also noticed that I would have to use the $r tag in the future with the same numbers, will they cause any issues? Is there a better way to display this? I am new to Twine so I am not sure… Any help would be greatly appreciated!

When using the <if> family of macro to perform a series of related evaluations, where only one of the series can be true at a time (known as Mutually Exclusive), it is better to use the <<elseif>> macro for the 2nd and later condition check…

<<if $r is 1>>A floating lamp<<elseif $r is 2>>A floating star<<elseif $r is 3>>UNKNOWN<</if>>

…that way the evaluation of that series will halt as soon as one of them is true. Otherwise all of the evaluations in the series are preformed.

note: if the series of evaluations check all possible conditions, like the how the value of $r can only be 1,2, or 3. Then an <<else>> macro can be used instead of the last <<elseif>>.

<<if $r is 1>>A floating lamp<<elseif $r is 2>>A floating star<<else>>UNKNOWN<</if>>

Alright, good to know… I do plan on making random number based mini games, will that collide with the current $r values that I currently have or not? Especially since I have a picture displaying in the sidebar as well as stats displayed in the sidebar using the same system. I’m just trying to see if I should change anything now while it’s easier since I don’t have that many variables written.

You can have very large numbers of variables, so there shouldn’t be any worry about having collisions. You can use $r in one place $x in another.

But I would advise using self-explanatory variable names, you will definitely thank yourself later when you are trying to remember what $r contains. If you call it $chosenCard instead, it will be a lot easier to use (even if it takes longer to type).