Problems with Math and Recognition of Variables (Solved)


#1

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)


#2

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


#3

i will try and see if works.


#4

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


#5

i think this requires more ()'s

like

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

#6

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))


#7

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

thanks


#8

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…


#9

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: