Not a Number:

So I know I asked for help about 2 hours ago and everything was going great until I ran into another problem I couldn’t figure out how to fix by myself. (I’m not sure if there’s a less bothersome way of getting specific questions answered)

Anyway
This is the stat im trying to work with
text Strength Strength
and it has stars that shade in indicating the points
*if (strength = 0)
*set strength “☆☆☆☆☆”
*if (strength = 1)
*set strength “★☆☆☆☆”
ect.

When I try to get a star filled in during a choice, it says
Not a number: ☆☆☆☆☆

This is what i’m doing:
*choice
#Yes of course I’ll help her.
*set strength +1
*goto helped_her
#Uh no, that’s not my problem.
*goto didn’thelp_her

Line 121 where I say *set strength +1 is where it responds with “Not a number: ☆☆☆☆☆”

If you have defined Strength as ☆☆☆☆☆ and then try to + 1 it later, it will error out because it’s a non-numeric character string and it cannot add to it.

You would need to set strength as 0 (or any other number) before you can use it in a math statement.

1 Like

This is the resource you want on data types: Data types | ChoiceScript Wiki | Fandom.

Note in particular the difference between *creating a numerical variable and a string variable–you may wish to create an additional string variable (strengthstars–or whatever) to display the stars.

3 Likes

How do you recommend I do that?

The error message you’re encountering, “Not a number: ☆☆☆☆☆,” suggests that there might be an issue with the way you’re manipulating the “strength” variable. The ChoiceScript interpreter is expecting a number for arithmetic operations, but in this case, it’s receiving a string value ☆☆☆☆☆

To resolve this issue, you can adjust your code to convert the “strength” variable into a numeric value before performing the addition Here’s an example of how you can modify your code

*choice
  #Yes, of course I'll help her.
    *set strength (strength + 1)
    *goto helped_her
  #Uh no, that's not my problem.
    *goto didn't_help_her

By enclosing (strength + 1) in parentheses, you ensure that the value is treated as a numerical expression rather than concatenating it as a string This allows the arithmetic operation to be performed correctly

Additionally, make sure that you have initially set the “strength” variable as a numeric value (e.g., *create strength 0) at the beginning of your game or scene so that it can be incremented or modified in subsequent choices

I hop that slove your problem

I tried that but the issue persist I’ll keep trying to fix it

strength has been set to zero the entire time so i’m just not sure how I can specifically solve my issue

Variables can be of different types. Text variables have a string of text as content and numeric variables have numbers as content. You can’t add up text to numbers and vice versa.

If you do *create strength_1 "something inside quotes" the value of strength would be whatever you put inside quotes.
If you do *create strength_2 5 the value of strength would be numeric 5

You can’t compare a text value to a numeric value, like *if strength_1 = 0 cause "something inside quotes" isn’t a number.

Your question is already answered in your last post.

@NitrogenPerfume So i didn’t understand your problem correctly for the first time but know I know what you want you want so you want the stars to dynamically update based on the value of the “strength” variable well for that you can use a combination of string concatenation and conditional statements Here’s an example of how you can modify your code

*choice
  #i will beat you goku
    *set strength +1
    *goto helped_her
  #i will forgive you goku
    *goto didn't_help_her

*label helped_her
*if (strength = 0)
  *set strength_stars "☆☆☆☆☆"
*elseif (strength = 1)
  *set strength_stars "★☆☆☆☆"
*elseif (strength = 2)
  *set strength_stars "★★☆☆☆"
*elseif (strength = 3)
  *set strength_stars "★★★☆☆"
*elseif (strength = 4)
  *set strength_stars "★★★★☆"
*else
  *set strength_stars "★★★★★"

...

*stat_chart
  text Strength Strength
  text Stars strength_stars

In this example the “strength_stars” variable is used to hold the string representation of the stars based on the “strength” variable’s value Using conditional statements (*if/*elseif/*else), you can set the value of “strength_stars” accordingly.

Make sure to include the *stat_chart command to display the Strength and Stars variables in the stats screen so players can see the updated stars as the strength value changes

4 Likes

This helps a lot! Thank you so much for your patience with me!

1 Like

The answer is pretty simple.

*create strength 0
*create strength_star "☆☆☆☆☆"

Strength is a numerical value, and strength_star is a string that reports the number of stars. Then just do what you were already doing.

1 Like

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