+1 vote
by (980 points)
For my character creation steps, I want them to fill out race, age, gender, skin color, hair color, and hair style; before moving on. So I want a check to see if those are defined. But I can't seem to get it to work for all. I got it to work to check if the player fills out race before they can select skin color, hair color, and hair style. I just do not know how to handle multiple variables in the if def statement.

 

<<if def $race and $gender and $age and $skinColor and $hairColor and $hairStlye>>
Now time to move on to the background information [[Background]]
<</if>>

 

What am I doing wrong?

2 Answers

+1 vote
by (68.6k points)
 
Best answer
<<if (def $race) and (def $gender) and (def $age) and (def $skinColor) and (def $hairColor) and (def $hairStlye)>>

Each sub-expression, the bits you're conjoining with logical-AND, within the aggregate conditional expression must themselves be whole and complete.

by (980 points)
You're Awesome! :) I did try () but I did not think to put def inside them. If you have not noticed... I am pretty much a complete newbie. I have so far been struggling and working things out on topics most probably just speeds through. I have also been watching a few tutorials to help with basics... there are so many things to learn and different ways to do things. Not sure yet how everything interconnects to know whether I am taking the correct routes.
+1 vote
by (8.6k points)

An alternative (and a bit shorter) way to TME's is to put all the values you want to test into a temporary array and check if they include an undefined value. In code:

<<if ![$race, $gender, $age, $skinColor, $hairColor, $hairStlye].includes(undefined)>>
Now time to move on to the background information [[Background]]
<</if>>

 

...