Issue with "non-existent variable" error

I’ve been reading some other posts about this but I haven’t found a solution to my issue, so here it goes. Maybe someone can help.

So I’m creating a test game to practice some of the things I’ve learned so far. At the beginning of the game I ask players to choose one of three races and each race has different stats. That worked fine.
But then later on I tried using the races to set another variable (not sure if my phrasing on this is right). What I mean is, the player is on a journey and I ask them which way they want to go. Depending on their answer and their race, their body temperature drops a different % (because there’s a storm and it’s cold and some races are faster than others, etc…). Like this:

Which way do you want to go?

    #North, towards the cave.
        *if dwarf
            *set body_temp %-15
        *if elf
            *set body_temp %-10
        *if human
            *set body_temp %-12
        *goto_scene cave_scene
    #East, towards the cabin
        *if dwarf
            *set body_temp %-20
        *if elf
            *set body_temp %-15
        *if human
            *set body_temp %-17
        *goto_scene house_scene

Whenever I try to choose any of these options, there’s an error saying Non-existent variable “dwarf”.

The first thing I tried was to switch places with the other races to see if it was just the “dwarf” that was giving problems, but the error popup kept appearing with the other races as well.

Initially, on my setup I wrote
*create race “Unknown”
But after this error I went back and wrote:

*create race "dwarf"
*create race "elf"
*create race "human"

And it still isn’t working. I can’t figure out why.
I also tried closing CSIDE and opening again, no luck.
Any ideas?

You don’t have a variable called dwarf.

When you type *if dwarf
You are saying… “Does the variable called dwarf equal true?”
You probably meant to do *if race = "dwarf"

Well, that sounds right and I’m feeling stupid for not thinking about it sooner. Gonna try that.
I wasn’t too sure how to do this, to begin with…

So from what I understand, I do need those *create race “dwarf” variables in my startup file, right?

EDIT: Your solution worked, thanks!

1 Like

If you *create race "" then you can set the variable race to whatever you want.
Here’s an example:

What race do you want to be?
  *set race "elf"
  *set race "dwarf"
  *set race "human"
  *set race "wolf"

Only *create race ? No “” after race needed?

Yes, you want *create race “”


@Gower is correct. The difference is that the quotation marks will tell the system that the variable is a string rather than a number.

*create race ""
*create race 0

Strings deal with letters and/or numbers, but are not really used for math.

So you would use *set race "dwarf" only if you’ve done *create race "" or similar
like *create race "default"
or *create race "elfvariant2"

1 Like