I need a tutor... HELP!

Ok as I said before maybe I’ve put the bar a little too high BUT and it is a BIG BUT I want to write this and apparently I am unable to find the answers myself… I feel very stupid I must admit.

Here is problem two for today…

Trying to see if I’ve got the stats page working ok but keep getting this message: choicescript_stats line 79: Non-existent variable ‘animalcare_text’

But here is everything I have linked to animal care.

Start up script:
*create animalcare 0

stat script:
*temp animalcare_text “”
*if (animalcare <25)
*set animalcare_text “Basic”
*goto chart
*elseif (animalcare <50)
*set animalcare_text “Learner”
*goto chart
*elseif (animalcare <75)
*set animalcare_text “Skilled”
*goto chart
*else
*set animalcare_text “master”
*goto chart

text animalcare_text Animal Care Level

I think I’m missing something big and important but cant work it out even with the tutrioals, wiki and youtube vids.

I’m going to try and take a crack at this, but I might not be the most qualified person to help… Though I have an idea or two.

The error says it’s on line 79. Can you point out which one is line 79? That might help with finding the error.

What happens if you *create animalcare_text “” in startup instead of as a *temp in the stats?

1 Like

“temp” stats only work in the document that they’re in. I don’t know how you set up your game documents, but I’ll use an example to help describe this.

Let’s say you have three documents:

  • Your startup document, where you create the “animalcare” stat
  • Your game documents, where you have all of the code and other writing for your game (You should have multiple game documents, one for each chapter or section, but the only one we need is the document that you wrote the “temp animalcare_text” in).
  • Your stats page, where you are trying to display the “temp animalcare_text” stat.

So, the problem is - like Gower said - the temp stat is only a stat in the document you created the temp stat in, which probably isn’t the stats page. So outside of the document it was created in, your “temp animalcare_text” stat doesn’t exist. To solve your problem, you just have the change the temp stat into a real stat by creating a *create animalcare_text “” into your startup page. Then your animalcare_text stat will exist throughout all of your game documents, and not just the one it was created in.

It worked for me

In startup

*create animalcare 34

You can change 34 with any number you like

In choicescript_stats

*temp animalcare_text ""
*if ( animalcare <= 25 )
	*set animalcare_text "basic"
*if (( animalcare > 25) and ( animalcare <= 50)) 
	*set animalcare_text "Learner"
*if (( animalcare > 50) and ( animalcare <= 75)) 
	*set animalcare_text "Skilled"
*if (( animalcare > 75) and ( animalcare <= 100)) 
	*set animalcare_text "Master"
*stat_chart
	text animalcare_text Animal Care Level

EDIT : elaborated on the solution

1 Like

Yeah the problem is that the temp variable is only good for the scene file it’s in. The choicescript stats counts as a separate file, so when you go into the stats page that variable is wiped and you’re telling ChoiceScript to display something that doesn’t exist.

Yopz. As most of us said, try moving *temp animalcare_text to *create animalcare_text on startup.txt

This wiki has more in-depth explanation about *temp usage.

Otherwise, try changing[quote=“Lilith_Darkness, post:1, topic:27099”]
text animalcare_text Animal Care Level
[/quote]

into

Animal Care Level: ${animalcare_text}

The result isn’t that different. And from coding perspective, I found out that using ${} parentheses gives more “freedom” than using *stat_chart

1 Like

line 79 : text animalcare_text Animal Care Level

Two things come to mind, though I’m unclear if either is actually an issue here. First: Is line 79 properly indented under a *stat_chart statement on line 78? 78 and 79 together should look something like this:

*stat_chart
    text animalcare_text Animal Care Level

Okay, technically you can put several different stat charts under a single *stat_chart statement, so the *stat_chart line 79 depends on doesn’t, strictly speaking, need to be line 78. But line 79 absolute does need to be indented under a *stat_chart somewhere nearby.

Second: Is the code that creates the temporary variable and sets its value (starting with *temp animalcare_text "") before or after lines 78 and 79? ChoiceScript needs to be able to run those lines before it gets to line 79 where the variable will actually be used.

If none of that works to clear up the issue, what happens if you try deleting the *temp animalcare_text "" line entirely, then add a *create animalcare_text "" in the startup.txt file?

thanks everyone for your help. Sort of couldn’t work it out even with your help so made my stats screen nice and simple.

Name: ${name}

Title: ${title}

Home: ${home}

School: ${school}

Potion Level: ${potion}

Animal Care Level: ${animalcare}

Crafting Level: ${crafting}

Business Level: ${business}

Cooking Level: ${cooking}

2 Likes

B… bu… bu… but… That’s exactly my help :cry:

2 Likes

i know and it really helped thanks.

Hey guys I know I’ve already decided to do it differently but you do understand that I did have my create in the startup and the temp in the stats right?

I figured what was wrong. I was setting up variables before putting them in the game so the tests must have seen them as useless or not needed. :grinning:
I did it!!

2 Likes