Halp! "Non-Existent Variable" Error

Driving me nuts, I keep getting this error and can’t figure out why… it seems like I’ve set it up right.

Error message: choicescript_stats line 58: Non-existent variable ‘home_text’

My code looks like this:
In my stats file I have:

*temp car_text
*if car = 0
  *set car_text "A broken down jalopy"
  *goto chart
*elseif car = 1
  *set car_text "The latest Tesla"
  *goto chart
*elseif car = 2
  *set car_text "A kickass Ferrari"
  *goto chart
*elseif car = 3
  *set car_text "A literal tank"
  *goto chart

*temp home_text
*if home = 0
  *set home_text "A dingy apartment"
  *goto chart
*elseif home = 1
  *set home_text "A nice house in a rough neighborhood"
  *goto chart
*elseif car = 2
  *set home_text "A nicely sized multi-family home"
  *goto chart
*elseif home = 3
  *set home_text "A ridiculously overpriced mansion"
  *goto chart

*temp business_text
*if business = 0
  *set business_text "none"
  *goto chart
*elseif business = 1
  *set business_text "A McNasty's Restuarant"
  *goto chart
*elseif business = 2
  *set business_text "A massage parlor and spa"
  *goto chart
*elseif business = 3
  *set business_text "A chain of undersea movie theaters"
  *goto chart
*label chart

*stat_chart
  text car_text Car
  text home_text Home
  text business_text Business

In my startup files I has:

*create car 0
*create home 0
*create business 0

How am I breaking it?

You’re skipping over the lines where you *temp home_text. Those *goto charts under the *if car = #s all need to *goto setting_home_text and you need a *label setting_home_text right above the *temp home_text. It should look something like this:

*temp car_text
*if car = 0
  *set car_text "A broken down jalopy"
  *goto setting_home_text
*elseif car = 1
  ...

*label setting_home_text
*temp home_text
...

(Obviously the same error will happen between the home and business variables too.)

Also, you should put an *else on the end of those *elseifs (with a *bug if you’re not expecting them to ever get used:

*elseif car = 3
  *set car_text "A literal tank"
  *goto chart
*else
  *bug Variable car was outside expected range. Range is 0 to 3, was ${car}.
2 Likes

Duhhhhhh, that makes total sense… obviously it’s past my bed time… THANK YOU! Staring at the screen blankly was making me crazy…