I’m really new to ChoiceScript but I’m trying to make it so that depending on what your highest stat is, your name will show up differently. This is my current code in choicescript_stats:
*temp title “Name”
*if (Charisma >= Endurance) and (Charisma >= Intellect) and (Charisma >= Strength)
*set title “The Alluring Moniker”
*elseif (Endurance > Charisma) and (Endurance >= Intellect) and (Endurance >= Strength)
*set title “The Time-Tested Moniker”
*elseif (Intellect > Charisma) and (Intellect > Endurance) and (Intellect >= Strength)
*set title “The Ingenious Moniker”
*elsif (Strength > Charisma) and (Strength > Endurance) and (Strength > Intellect)
*set title “The Imposing Moniker”
*stat_chart
text name ${title}
However, it’s showing the following error:
choicescript_stats line 2: Invalid expression at char 55, expected no more tokens, found: BOOLEAN_OPERATOR [and]
It seems to have a problem with there being more than two checks to set a title but I’m not sure why. Thanks very much in advance for any help!
[code]*temp title “Name”
*if (((Charisma >= Endurance) and (Charisma >= Intellect)) and (Charisma >= Strength)))
*set title “The Alluring Moniker”
*goto
*elseif (((Endurance > Charisma) and (Endurance >= Intellect)) and (Endurance >= Strength)))
*set title “The Time-Tested Moniker”
*goto
*elseif (((Intellect > Charisma) and (Intellect > Endurance)) and (Intellect >= Strength)))
*set title “The Ingenious Moniker”
*goto
*elsif (((Strength > Charisma) and (Strength > Endurance)) and (Strength >= Intellect)))
*set title “The Imposing Moniker”
*goto
Ok so @Lycoris is probably a lot more efficient, however I was curious so I played around with a different method. It’s slightly longer but allows for more detailed titles…
@Lycoris is correct, except… instead of *if (((Charisma >= Endurance) and (Charisma >= Intellect)) and (Charisma >= Strength)))
*set title “The Alluring Moniker”
*goto
you have to use *if (((Charisma >= Endurance) and (Charisma >= Intellect)) and (Charisma >= Strength))
*set title “The Alluring Moniker”
*goto
note the one less close bracket next to the last strength.
In an *if statement you can only give ChoiceScript two things to worry about at a time – any more and it crashes. The code in your initial example is giving them three, e.g.
*if (charisma >= endurance) and (charisma >= intellect) and (charisma >= strength)
To fix it, just take two of those things,
(charisma >= endurance) and (charisma >= intellect)
turn them into a single thing by adding another set of parentheses around them,
((charisma >= endurance) and (charisma >= intellect))
and then add the “third thing” back in at the end:
*if ((charisma >= endurance) and (charisma >= intellect)) and (charisma >= strength)
CS should parse that just fine, and the same process works for as many additional terms as you want to add (though if you add too many, it’ll be tricky to make sure you’ve used the right number of parentheses). Have a look at this thread for more examples: