Adding stats together

Hey I’ve been trying to add a few of my stats together (which were randomly put together if this helps) and I put this.

*set visible ((mental)+(age))

The thing is however when I go to my stat screen mental could be 7 and age could be 10 be it would give me an outrageous number like visible: 5439 I tried this multiple times and got something similar.

We would need to see all operations involving these variables as they might be strings and each digit might be being added together to form a string of concatenated numbers instead of a proper numerical operation.

1 Like

K give me one sec

*create mental 0
*create age 0
*create visible 0
*rand age 1 10
*if (age = 1)
 *goto jess
*if (age = 2)
 *goto jess1
*if (age = 3)
 *goto jess2
*if (age = 4)
 *goto jess3
*if (age = 5)
 *goto jess4
*if (age = 6)
 *goto jess5
*if (age = 7)
 *goto jess6
*if (age = 8)
 *goto jess7
*if (age = 9)
 *goto jess8
*if (age = 10)
 *goto jess9

*label jess
You are 1
*goto yy

*label jess1
You are 2
*goto yy

*label jess2
You are 3
*goto yy

*label jess3
You are 4
*goto yy

*label jess4
You are 5
*goto yy

*label jess5
you are 6
*goto yy

*label jess6
You are 7
*goto yy

*label jess7
You are 8
*goto yy

*label jess8
You are 9
*goto yy

*label jess9
You are 10
*goto yy

*label yy
*page_break

*rand mental 1 10
*if (mental = 1)
 *goto jess11
*if (mental = 2)
 *goto jess111
*if (mental = 3)
 *goto jess21
*if (mental = 4)
 *goto jess31
*if (mental = 5)
 *goto jess41

*label jess11
You are 1
*goto end

*label jess111
You are 2
*goto end

*label jess21
You are 3
*goto end

*label jess31
You are 4
*goto end

*label jess41
You are 5
*goto end

*label end
*page_break
Ok this is the end

Stat screen

*set visible  ((mental) + (age))

My thing is there should be no way the numbers are up in the thousands.

Hm. Any other operation/calculation happening on your stats_screen?


Also, unrelated to your problem, but why

*if (age = 1)
  *goto jess

and not

*if (age = 1)
  You are 1
  *set age +1

Just streamlining things so they’re easier to track.

1 Like

No that all that’s there is rest of it’s is just coding, text, and *if statments.

I don’t know I wanted the player to know what they rolled mentally since they could possibly turn off the roll feature (they would choose their own age)

Try

*set visible (mental + age)

Also, you should probably not add the age/mental again in the various labels.

If the randomizer generates (age = 2), it heads to the label jess1 (You are 2) and then adds another 2 to that age, resulting in (age = 4).

You can also do

You are ${age}.
You are ${mental}.

To display the value of the variable to the player.

1 Like

The age and mental age are used to tell your visible age and let the player know how they looked to others caused it would affect how other characters treated you. It would be weird if the character was 3 with the mental age of 5 looking over 100 years old (mentioning this made me realize something however) and thank you for mentioning that also.

That still doesn’t explain why the numbers are in the thousands.

Ok I fixed that issue but the answer is still in the thousands.

Do you mind posting all your stats_screen and all the scene codings?

I copied your code into CSIDE and don’t get results that high.

Are there really no other lines of code that influence the variables visible, mental, and age? Like Szaal said, it’d be helpful if we could get a look at the rest of the code for troubleshooting.

There is literally no other code it’s all I have aside from 3 choices which have nothing to do with this code. I downloaded a new file and tested it out on blank game(No code aside from the code mentioned above), I wanted to test it before I implemented it into my own game.

The only other thing I’m noticing is that if the maximum mental age you’re having a label for to display it to the reader is 5, then you should put

*rand mental 1 5

instead of mental 1 10.
Right now, if the (mental > 5) (so = 6, 7, 8, 9 or 10), the code will jump to *label jess11 and display “You are 1” but the value is actually a higher number.

As I mentioned before, you’ll have it easier if you do it just like this:

Your age is ${age}.
Your mental age is ${mental}.

This will automatically output the value of the variables as rolled by the die.

None of that solves your problem with the endresult for visible being in the thousands. It’s not for me when testing the code in CSIDE, so I’m at a loss.

Even if you don’t think the rest of the code is important, it’s really best to just show it all to us. All the code in your test file and all the code that’s in the stats file, just so that we can make sure.

*create mental 0
*create age 0
*create visible 0
*create name ""

*label z
What's your name?
*input_text name
*goto y

*label y
Oh so your name is $!{Name}
*choice
  #Yup
   *goto x

  #Nope
   *goto z

*comment Remind Jess about the next chapter

*label x
Not like that matter anyways I just need to test something for another game. Not like this choice matters either.

*choice 
  #Oh well
   *goto w

  #Oh well
   *goto w

*label w

*rand age 1 10
*if (age = 1)
 *goto jess
*if (age = 2)
 *goto jess1
*if (age = 3)
 *goto jess2
*if (age = 4)
 *goto jess3
*if (age = 5)
 *goto jess4
*if (age = 6)
 *goto jess5
*if (age = 7)
 *goto jess6
*if (age = 8)
 *goto jess7
*if (age = 9)
 *goto jess8
*if (age = 10)
 *goto jess9

*label jess
You are 1
*goto yy

*label jess1
You are 2
*goto yy

*label jess2
You are 3
*goto yy

*label jess3
You are 4
*goto yy

*label jess4
You are 5
*goto yy

*label jess5
you are 6
*goto yy

*label jess6
You are 7
*goto yy

*label jess7
You are 8
*goto yy

*label jess8
You are 9
*goto yy

*label jess9
You are 10
*goto yy

*label yy
*page_break

*rand mental 1 10
*if (mental = 1)
 *goto jess11
*if (mental = 2)
 *goto jess111
*if (mental = 3)
 *goto jess21
*if (mental = 4)
 *goto jess31
*if (mental = 5)
 *goto jess41

*label jess11
You are 1
*goto end

*label jess111
You are 2
*goto end

*label jess21
You are 3
*goto end

*label jess31
You are 4
*goto end

*label jess41
You are 5
*goto end

*label end
*page_break
Ok this is the end

The stat section

*stat_chart
 text visible

*create name should be *create name "" so that you have a string variable.

You don’t need a *goto y if *label y is the next line in this instance.

Oh so your name is $!{Name}

There you use Name for the variable, but you created it as name with a lower case letter.

Not a mistake per se, but instead of *if (age = 1) it is simpler to just say *if age = 1

Didnt notice i wonder why it didn’t give me an error? Let me go fix that so I don’t get an error later.

Try this in your stat screen instead of doing the *set there.

*stat_chart
	text visible (mental + age)

From my experience (using CSIDE), the variables are not case sensitive, just what you set them to is. But having a variable {age} and then writing

${age}
${AGE}
${aGe}

will all output the value of the variable {age}.
What did give me an error in CSIDE was that the choice options in label x were identical, but that could be just CSIDE.

About this:

*stat_chart
	text visible (mental + age)

This results, for me, in this because what’s after the second space changes the displayed text:

(mental + age): 0

I’d do something like this instead:

*set visible (mental + age)
*stat_chart
 text visible

Also, I know I’m repeating myself, but about

*rand mental 1 10

Is “mental” supposed to be able to be any number from 1 to 10? If yes, then you’ll need to add more of your *if age = X for the missing numbers 6, 7, 8, 9, 10.

Ok I’ve fix the ${name} although it never has given me trouble before I should probably change it on my other games just in case.

Mental is 1 to 5 for now I’m gonna make it larger layer I just want this to work first. The choices work fine it might be a warning from C-SIDE just in case someone accidentally wrote a question twice. Gonna try the suggestion by you and @Gower.

Ok it sortaish work some times it adds up correctly sometimes its 1 or 2 off :hushed:

Well at least it isn’t in the thousands anymore.