Difference between codes

Hey everybody,

I created a “heat” variable and for some reason it wont work. the strange part is, that my “health” variable works just fine yet I cant find ANY Difference between the two codes. why is one working and the other one dont? and how do I fix it? Thanks

The “heat” code:

*temp heat_text

*if heat = 0
  *Set heat_text "Anonymous"
  *goto chart
*elseif heat = 1
  *Set heat_text "Barely heard of"
  *goto chart
*elseif heat = 2
  *set heat_text "Well known"
  *goto chart
*elseif heat = 3
  *set heat_Text "Wanted"
  *goto chart
*elseif heat = 4
  *set heat_text "Public Enemy"
  *goto chart
*elseif heat = 5
  *set heat_text "International Sensation"
  *goto chart

and in the top of startup:

*create heat 0
*create heat_text ""

And the “health” code:

*temp Health_text

*if Health = 0
  *set Health_text "Uninjured"
  *goto chart
*elseif Health = 1
  *set Health_text "Just a Scratch"
  *goto chart
*elseif Health = 2
  *set Health_text "Slightly Injured"
  *goto chart
*elseif Health = 3
  *set Health_text "Injured"
  *goto chart
*elseif Health = 4
  *set Health_text "Seriously Injured"
  *goto chart
*elseif Health = 5 
  *set Health_text "Got nothing left"
*elseif Health = 6
  *set health_text "Dead"
  *goto chart
*elseif health = 7
  *set health_text "Busted"
  *goto chart

And in the top of startup:

*create health_text ""
*create health 0

The stat chart:

Health: ${health_text}
*line_break
Heat: ${heat_text}

Please take note that the variable Health_text is not the same as the variable health_text and that the variable Health is not the same as the variable health since ChoiceScript is case sensitive.

Oh, and that you don’t need

if you’ve already got

(I think we went through that last thing last time already, so I’ll leave it at that.)

About the case sensetive variable, I never encountered any problem caused by this. As I said, health variable works fine.

As for the temp\create, If I dont have a *create command I get “non existing variable” error; if I dont have *temp command I cant change the text using numbers, I have to type the text itself (something I dont want to happen here - I want it to act like the “Health”)

Do you still remember

That one worked without a *temp variable, so these two examples should work without them too.
and

In the case of the ‘health’ variable the order of precedence isn’t an issue because you’ve got two different variables (Health_text and health_text), but with the ‘heat’ variable it is because you’ve got a temporary and a permanent variable going by exactly the same name.

It still wont work; removed the *temp and fixed the upper/lower case

I’ve got working code again. Please compare it with what you’ve got right now. That should teach you more than any explanation from my side ever would.

startup.txt (+code for testing purposes):

*title Test

*create rep_text "Neutral"
*create rep 0
*create name ""
*create gender_text ""
*create money 0
*create health 0
*create health_text "Uninjured"
*create heat 0
*create heat_text "Anonymous"


*label setrep
*choice
    #set rep 0
        *set rep 0
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 1
        *set rep 1
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 2
        *set rep 2
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 3
        *set rep 3
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 4
        *set rep 4
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 5
        *set rep 5
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 6
        *set rep 6
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 7
        *set rep 7
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 8
        *set rep 8
        You changed your reputation.
        *page_break
        *goto setrep
    #set rep 9
        *set rep 9
        You changed your reputation.
        *page_break
        *goto setrep
    #set heat 0
        *set heat 0
        You changed your heat.
        *page_break
        *goto setrep
    #set heat 1
        *set heat 1
        You changed your heat.
        *page_break
        *goto setrep
    #set heat 2
        *set heat 2
        You changed your heat.
        *page_break
        *goto setrep
    #set heat 3
        *set heat 3
        You changed your heat.
        *page_break
        *goto setrep
    #set heat 4
        *set heat 4
        You changed your heat.
        *page_break
        *goto setrep
    #set heat 5
        *set heat 5
        You changed your heat.
        *page_break
        *goto setrep
    #set health 0
        *set health 0
        You changed your health.
        *page_break
        *goto setrep
    #set health 1
        *set health 1
        You changed your health.
        *page_break
        *goto setrep
    #set health 2
        *set health 2
        You changed your health.
        *page_break
        *goto setrep
    #set health 3
        *set health 3
        You changed your health.
        *page_break
        *goto setrep
    #set health 4
        *set health 4
        You changed your health.
        *page_break
        *goto setrep
    #set health 5
        *set health 5
        You changed your health.
        *page_break
        *goto setrep
    #set health 6
        *set health 6
        You changed your health.
        *page_break
        *goto setrep
    #set health 7
        *set health 7
        You changed your health.
        *page_break
        *goto setrep

choicescript_stats.txt:

*if rep = 0
    *set rep_text "Neutral"
    *goto heat
*elseif rep = 1
    *set rep_text "Positive"
    *goto heat
*elseif rep = 2
    *set rep_text "Very Positive"
    *goto heat
*elseif rep = 3
    *set rep_text "Amazing"
    *goto heat
*elseif rep = 4
    *set rep_text "Hero"
    *goto heat
*elseif rep = 5
    *Set rep_text "Living Legend"
    *goto heat
*elseif rep = 6
    *set rep_text "Negative"
    *goto heat
*elseif rep = 7
    *set rep_text "Very Negative"
    *goto heat
*elseif rep = 8
    *set rep_text "Hated"
    *goto heat
*elseif rep = 9
    *set rep_text "Tyrant"
    *goto heat

*label heat

*if heat = 0
  *set heat_text "Anonymous"
  *goto health
*elseif heat = 1
  *set heat_text "Barely heard of"
  *goto health
*elseif heat = 2
  *set heat_text "Well known"
  *goto health
*elseif heat = 3
  *set heat_text "Wanted"
  *goto health
*elseif heat = 4
  *set heat_text "Public Enemy"
  *goto health
*elseif heat = 5
  *set heat_text "International Sensation"
  *goto health

*label health

*if health = 0
  *set health_text "Uninjured"
  *goto chart
*elseif health = 1
  *set health_text "Just a Scratch"
  *goto chart
*elseif health = 2
  *set health_text "Slightly Injured"
  *goto chart
*elseif health = 3
  *set health_text "Injured"
  *goto chart
*elseif health = 4
  *set health_text "Seriously Injured"
  *goto chart
*elseif health = 5 
  *set health_text "Got nothing left"
*elseif health = 6
  *set health_text "Dead"
  *goto chart
*elseif health = 7
  *set health_text "Busted"
  *goto chart

*label chart

Character
*stat_chart
  text Name
  text gender_text Gender
  text Money
  text rep_text Reputation
  text heat_text Heat
  text health_text Health
1 Like

But does the rep_text change according to the rep itself changing?

It did when I ran this code. Doesn’t it change when you test it?

Nope. It dosen’t change.

See:


Have you perhaps got some other code in there as well? Or have you changed anything?

Actually Choicescript forces every variable to lowercase, so they’re essentially the same and will take precedence (or not) over one another.

Ok. To be honest I never tested it with variables themselves, only with values.

It can confuse testing, though. In quicktest if you have MorningScene in your scene list but the file is called morningscene.txt, it will give you duplicate readings of untested lines for “both” scenes. And of course it’ll screw up strings; *if gender=“female” won’t work if you originally set gender to be “Female”. So it’s good to keep cases standard.

Of course, I was by no means encouraging people to use uppercase in variable names, I apologise if this was implied! :blush:

As far as gender goes I suggest using booleans for that exact reason.