Problem with using Variable Stat Titles


#1

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!


#2

Maybe something like this?

[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

*label
*stat_chart
text name ${title}[/code]


#3

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…


*temp Charisma1 0
*temp Endurance1 0
*temp Intellect1 0
*temp Strength1 0

*if (Charisma >= Endurance)
	*set Charisma1 +1
	*goto part2
*else
	*set Endurance1 +1
	*goto part2
*label part2
*if (Intellect >= Strength)
	*set Intellect1 +1
	*goto part3
*else
	*set Strength1 +1
	*goto part3
*label part3
*if (Strength >= Charisma)
	*set Strength1 +1
	*goto part4
*else
	*set Charisma1 +1
	*goto part4
*label part4
*if (Endurance >= Intellect)
	*set Endurance1 +1
	*goto part5
*else
	*set Intellect1 +1
	*goto part5
*label part5
*if (Charisma >= Intellect)
	*set Charisma1 +1
	*goto part6
*else
	*set Intellect1 +1
	*goto part6
*label part6
*if (Endurance >= Strength)
	*set Endurance1 +1
	*goto part7
*else
	*set Strength1 +1
	*goto part7
*label part7

*if Charisma1 >2
	*set title "The Alluring Moniker"
	*goto part8
*elseif Endurance1 >2
	*set title "The Time-Tested Moniker"
	*goto part8
*elseif Intellect1 >2
	*set title "The Ingenious Moniker"
	*goto part8
*else
	*set title "The Imposing Moniker"
	*goto part8
*label part8

That may seem slightly longer but it allows you to add:


*if Charisma1 =2
	*set title2 "Alluring"
	*goto part9
*elseif Endurance1 =2
	*set title2 "Time-Tested"
	*goto part9
*elseif Intellect1 =2
	*set title2 "Ingenious"
	*goto part9
*else
	*set title2 "Imposing"
	*goto part9
*label part9

So that if you wanted you could have

${title} who is slightly ${title2}

E.g
The Alluring Moniker who is slightly Imposing

I would stick with Lycoris’s method, but this entertained me for a few minutes of trialing.


#4

@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.


#5

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:


#6

Thanks very much guys!