QUICKTEST FAILED Error: choicescript_stats line 88: Invalid expression at char 14, expected NUMBER, STRING, VAR or PARENTHETICAL, was: INEQUALITY [<]

Hi everyone, first post here! I’m having trouble with setting up a Hit Points value in my stat screen

The error I’m getting is: Error: choicescript_stats line 88: Invalid expression at char 14, expected NUMBER, STRING, VAR or PARENTHETICAL, was: INEQUALITY [<]

My code is:

*temp current_health_text
*if currenthp = (<maxhp and ((>=(maxhp / 2)))
        *set  current_health_text "Mildly wounded"
*if currenthp = (<= (maxhp/2) and ((>=(maxhp / 3)))
        *set  current_health_text "Seriously wounded"
*if currenthp = (<= (maxhp/4) and (( maxhp > 0 )))
        *set  current_health_text "Mortally wounded"

I’m trying to make it so that the variable currenthp is compared to the value of maxhp and sets the temp variable current_health_text to the corresponding text…

I’m sure it’s something super simple and dumb that I’m missing, this is my first time with a Choicescript game

For this:

Use this:
*if ((currenthp < maxhp) and ((currenthp) >= (maxhp / 2)))

Someone else can tell me if there’s a better parenthesis configuration; perhaps I have an extra unneeded pair in there, but in general if you have a different number of left and right ones, something is wrong, as in the one you did.

Also, note:

If you want to ask if something is equal to or less, you say *if X <= Y.
If you want to ask if something is less than something and also greater than something, you say
*if ((x < y) and (x > z))

2 Likes

*if ((currenthp < maxhp) and (currenthp >= (maxhp / 2)))

Should work. The parenthesis around ‘currenthp’ are not necessary.

3 Likes

Altaiir is right about the parentheses, but also, be sure to initialize your *temo var, in order to type it.

Instead of this:
*temp current_health_text

You want this:
*temp current_health_text ""

But the parentheses is really the essential part.

By the way, what programming language did you work with before? Your use of gt/lt operators is way different than anything I know.

1 Like

This was it! I felt so dumb when it worked just like that, thank you!

If this is a question for me then I shamefully have to admit that… I had never seriously “worked” with any programming language before. The most I ever did was fool around with Python for a couple weeks, but that’s it. What’s a gt/lt operator, if you don’t mind me asking?

Greater than (>) / Less than (<)

Everyone starts somewhere. There’s really no reason to be ashamed. Luckily for you, choicescript is the easiest language there can be. Experiment for a few days and you will be good to go.

Ahhh got it! haha I knew it had to be something simple, thanks for explaining!

Thank you! So far I’m having a lot of fun and the community seems very helpful and kind. Thanks for the help!

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.