Nonexistent Variable Error


#1

When I was creating the health bar, it created a Nonexistent variable error.

When I was in the startup menu, I wrote:

*create sanity 0
*create insanity 0
*create hypersomnia 0
*create morality 0
*create immorality 0
*create relationship 0
*create hunger 0
*create health 100

When I was in the choicescript_stat menu, I wrote:

*stat_chart
text Name
text Gender
text Hair
text Nationality
text Personality
text Family
text Type
text Specialization
text Quirk
text Realm
text Weapon
opposed_pair Sanity
Insanity
opposed_pair Morality
Immorality

percent Psyche

percent Health
*if (health <=100) and (health > 95)
Fine
*if (health <=95) and (health > 70)
Good
*if (health <=70) and (health > 50)
Okay
*if (health <=50) and (health > 30)
Danger
*if (health <=30) and (health > 10)
Grave Danger
*if health <=10
Critical

Yet it still says variable 21 “health” is non-existent when I open the choicescrip_stat page only when I open the page in Google Chrome. How do I fix this error?


#2

Chrome doesn’t play nicely with ChoiceScript. From http://choicescriptdev.wikia.com/wiki/Development_Tools:

Note that Google Chrome is considered a poor choice for most ChoiceScript authors as this browser does not
support local scripting and does not give out error messages. Although a
technical workaround is known to exist to allow it to work offline,
most ChoiceScript authors using Chrome can only test their game by
uploading it online. This is inefficient in comparison, and is not
recommended.

If it works in Firefox, call it good and keep going.


#3

I’m not sure but you might need a space between the </=/> and the number. Also I found I had to use double brackets to get things to work often.
ie: *if (( ) and ( ))
Also you only need one variable for opposed stats (ie immorality or morality, not both).

Not sure if this will fix the problem but worth a go.


#4

It may be your brackets?
For instance:

*if ((variable <= 100) and (variable > 90))
   Fine 

Also it’s good habit to put brackets around the

*if (variable <= 10)
   Critical  

Also did you create a health variable in startup.txt?


#5

I already created a health variable in startup.txt. And it seems to be working now. Thank you very much?


#6

Not sure which thing you did to get it working but glad it’s working now for you.