Problems with Math and Recognition of Variables (Solved)

I’m having trouble with with math, i want the code to recognize different variables and make addition of these variables and show in the stats screen.
The variable Head_life have the value of 1 the remainder has a value of 0, what I intended was to add these variables presented and by the logic the final text should be 1. this is a test tha i did.

My code looks like this:

Armor Stats
*stat_chart
text Life (Head_life + Body_life + LeftArm_life+ RightArm_life+ Legs_life)

I think you need a
*set life head + legs etc
somewhere at the beginning of the stats file before that IIRC
and have it just be
*stat_chart
text life life

I think

1 Like

i will try and see if works.

Now i get the error Armor_Stats line 8:Invalid expression at char 63, expected no more tokens,found: OPERATOR [+]

i put the code this way:
Armor Stats
*set life (Head_life + Body_life) + (LeftArm_life + RightArm_life) + (Legs_life)
*stat_chart
text life

i think this requires more ()'s

like

*set life (((head_life) + (body_life)) + (legs_life)))
1 Like

You have one too many right parens–the errant one is at the end. Try this–see if it works:

*set life (((head_life) + (body_life)) + (legs_life))

1 Like

its worked now my code is this
*set life (((head_life) + (body_life)) + (legs_life)) + ((LeftArm_life) + (RightArm_life))

thanks

I’m always amused how people curse and swear at indents, while these bloody parens give me a migraine… every time.

especially since it always complains to me if the number of the final ones doesn’t match the first ones…

2 Likes

There’s a user-made plugin for Notepad++ 32bit to check the balance of those parens, btw. I’m having a lot of fun with it :grimacing:

If you can remember that CS can only cope with two items at a time, that makes it easier. e.g. (1 + 2) is two items, (1 + 2 + 3) is three items and confuses the engine. That’s why you need the parentheses (1 + 2) + 3 works because it does the two items in the parentheses first, turning them into just one item.

1 Like