Name error

I’m having trouble with my stats screen I’ve looked at the many topics on what’s happening but have come up with no solution.

The error I’m getting is; choicescript_stats line 4: Non-existent variable ‘name’

My code looks like this:

*stat chart
text name
percent 50 health
percent 0 strength
percent 0 speed
percent 0 stamina
percent 0 leadership
percent 0 camouflage
percent 0 cuteness
percent 0 pride/herd/pack size

Startup screen

*create name “Unknown”

1 Like

Is the stats screen snippet the exact way it appears on your text editor (i.e. are there also no indents or underscores in the code)?

It’s exactly how it looks in the text editor, I kept wondering what I did wrong, so I would go and look how to do it only for the guide to show me exactly what I have.

Is there an underscore in *stat_chart?

Yes

Just to give a visual of what @Writing_Fever and @SpokesWriter is pertaining to…

in choicescript_stat.txt, it should look exactly like this:

*stat_chart
	text name
	percent 50 health
	percent 0 strength
	percent 0 speed
	percent 0 stamina
	percent 0 leadership
	percent 0 camouflage
	percent 0 cuteness
	percent 0 pride/herd/pack size

Yes, it looks exactly like that

Could you paste it in using code tags?

Highlight it and hit the little </> button.

Huh. That’s weird. Could you show us your entire code in your choicescript_stats.txt? You mention it says the error was in line 4, but when I coded this, the “text name” is in line 2.

*stat_chart
  text Name
  percent 50 health
  percent 0 strength
  percent 0 speed
  percent 0 stamina
  percent 0 leadership
  percent 0 camouflage
  percent 0 cuteness
  percent 0 Pride/Herd/Pack size

Try using “name” instead of “Name”

EDIT: Never mind, it still worked for me.

EDIT#2: So I copied and pasted your code, and I saw that you used two spaces instead of a tab for indentions. Try replacing them with a tab instead.

Doing that didn’t help sadly, it still gives me the error: choicescript_stats line 4: Non-existent variable ‘name’

For whatever reason, the code didn’t register the stat [name] in your startup.txt. Try adding this above your *stat_chart.
Name: ${name}


On the other hand, may we see the entirety of your startup.txt?

1 Like
  *create name "Unknown"
  *create cuteness 0
  *create strength 0
  *create stamina 0
  *create health 0
  *create leadership 0
  *create speed 0
  *create camouflage 0
  *create pride/Herd/Pack size 0

  *set cuteness +20
  *set strength +20
  *set leadership +20
  *set pride/Herd/Pack size +1
name: ${name}

*stat_chart
	text name
	percent 50 health
	percent 0 strength
	percent 0 speed
	percent 0 stamina
	percent 0 leadership
	percent 0 camouflage
	percent 0 cuteness
	percent 0 pride/Herd/Pack size

I think it’s because “name” isn’t really a numerical value so it can’t be a stat? Try putting “text name” above the “*stat_chart”

Nevermind I tried it in CSIDE and I think I know what the prob is?

So this startup.txt works:

And this stats page will get you this:

Is this close to what you wanted?

The issues I found copypasting the code in was:

  • startup didn’t like spaces before *create
  • I think it also has a problem with “/” in your variables so I got rid of it
  • If also didn’t like the space in “Pack size” so I turned that into “Packsize”
  • I got rid of the “0” in the stats page because it just reset the stats to “0” and I don’t think that’s what you wanted? If you want the stats to start out as a certain number you can put that in “*create” inside of doing a seperate set of “*set”
    i.e write “*create cuteness 20” instead of both *create cuteness 0" and “*set cuteness +20” in startup

Hope I helped~ Good luck with your WIP :smile:

1 Like

Umm, sorry if I’m misreading things, but you have put name : ${name} already, why would you need to put text name in the *stat_chart?

@Szaal got it, thanks for explaining it to me :+1:

1 Like

OP’s problem is in the *stat_chart. The Name: ${name} is my suggestion to try narrow down the bug.


Which I think I understand what’s happening.
Don’t indent your *create list, @puppo.

2 Likes

Yes. There are specific, strict rules for creating variable names. A variable name can contain alphanumeric characters and underscores, and must start with a letter or underscore, not a digit.

pride_size: :heavy_check_mark: valid variable name

pridesize: :heavy_check_mark: valid variable name

pride2_size: :heavy_check_mark: valid variable name

pride size: :x: wrong! invalid variable name!

No spaces, no hyphens or slashes or commas or other punctuation marks. Only underscores.

Hope this helps.

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.