Variables not working?

I’ve been trying to use variables in such a way they aren’t displayed on the stat screen at all, but when I do this they seem to not work. However, when I do use the stat screen to show my variables everything works great. Can someone help please?

Are you sure that they aren’t working? What makes you think they aren’t working? What sort of error messages are you getting?

It might help to if we could see the code.

I have it set up so that depending on which choice you pick in a *fake_choice it will increment a variable by one, but unless I have a *stat_chart SOMEWHERE it won’t compare my variable in *if statements at then end when I have things like
*if (var1 > var2)
*if (var1 > var3)
Var1 is greatest
It just crashes
(sorry, I’m in a hurry whilst writing this!)

*create Syltherin 0
*create Griffindor 0
*create Hufflepuff 0
*create Ravenclaw 0

*title SORTING HAT
*author Prof. Bob

Well, you've been invited to Hogwarts... Please enjoy your stay!
*page_break

So, first you must be sorted!
*line_break
Let's get started!
*page_break

You must awnser a series of questions, here is the first, A muggle comes to you and says, "GET OFF MY LAWN!!!" and has what looks like a primate non-magic sword, what do you do?

*fake_choice
    #Snarl, and slowly walk off his lawn
        *set Syltherin +1
    #Say, "Oh, I'm so sorry... I'll leave now!" and quickly get off his lawn
        *set Hufflepuff +1
    #Say, "Oh, okay."
        *set Griffindor +1
    #Make an argument on why you whould be able to be on his lawn
        *set Ravenclaw +1

2. You hear from your friend Tom that your "friend" Pete has been spreading horrible rumors about you. What do you do?
*fake_choice 
    #RUMORS?!!! Let's start spreading rumors about him and see how [i]he[/i] likes it!
        *set Syltherin +1
    #Rumors? Lemme go talk to him.
        *set Griffindor +1
    #Rumors? Whatever.
        *set Hufflepuff +1
    #Oh my, Rumors! I better get a teacher...
        *set Ravenclaw +1
    
3.You have OWL exams coming up! What do you do?
*fake_choice
    #Eh, it can wait. I'll do fine.
        *set Griffindor +1
    #Exams! Who cares about exams??
        *set Syltherin +1
    #Exams! I should help people study!
        *set Hufflepuff +1
    #Why are you telling me? I've been studing for two months!
        *set Ravenclaw +1

4.Somebody has anonymously challenged you to a duel after hours in the trophy room. Alone. What do you do?
*fake_choice
    #Go! (But make sure someone knows where I am!)
        *set Griffindor +1
    #Someone could get hurt! Of course not.
        *set Hufflepuff +1
    #WHAT?!?! That's against the rules! Better find a teacher...
        *set Ravenclaw +1
    #Go, but take two friends with me. I'm gonna pulverize this guy.
        *set Syltherin +1

5.You heard a rumor that Bob, a Syltherin, is going to do something nasty! However, you don't know what...
*fake_choice
    #Tell a teacher!
        *set Ravenclaw +1
    #Find out more.
        *set Griffindor +1
    #Someone will find out. I don't need to worry.
        *set Hufflepuff +1
    #Let him. He probably won't do it to me, so what do I care?
        *set Syltherin +1


For now this is all I am going to ask you let me calculate your scores!
*page_break

*if (Syltherin > Griffindor) and (Syltherin > Hufflepuff) 
    *if Syltherin > Ravenclaw
        Hmmm, I think, SYLTHERIN!!!!!!

        You finished with these scores!
        *stat_chart
            text Syltherin
            text Hufflepuff
            text Griffindor
            text Ravenclaw
        *finish
*if (Griffindor > Syltherin) and (Griffindor > Hufflepuff)
    *if Griffindor > Ravenclaw
        Well, I think, no, ummm, I think you're GRIFFINDOR!!!!!!

        You finished with these scores!
        *stat_chart
            text Syltherin
            text Hufflepuff
            text Griffindor
            text Ravenclaw
        *finish
*if (Hufflepuff > Griffindor) and (Hufflepuff > Syltherin)
    *if Hufflepuff > Ravenclaw    
        Ah, I see, you're definatly, most certainly, absoultely, certifiably, HUFFLEPUFF!!!!!!

        You finished with these scores!
        *stat_chart
            text Syltherin
            text Hufflepuff
            text Griffindor
            text Ravenclaw
        *finish
*if (Ravenclaw > Griffindor) and (Ravenclaw > Syltherin)
    *if Ravenclaw > Hufflepuff
        Well, a smart one I see, you're a RAVENCLAW!!!!!

        You finished with these scores!
        *stat_chart
            text Syltherin
            text Hufflepuff
            text Griffindor
            text Ravenclaw
        *finish
    *finish
*else
    You have a tie! We will ask you a questino with only two awnsers, pick accordingly!

    *if Syltherin = Griffindor
        6.

Btw this code has been ffixed to accomedate the problem
(I was mainly wondering if this was a bug or not.)

Do you mean stat screen, or do you mean just using a stat chart? I don’t actually see why either matters. Unless your stat screen has stats that don’t actually exist in your game.

Isn’t it Slytherin not Syltherin?

Also why aren’t you doing

*if (((Hufflepuff > Griffindor) and (Hufflepuff > Syltherin)) and (Hufflepuff > Ravenclaw))

A pitch to the community, did *fake_choice get altered to allow *set to work in them? Last time I check (which was admittedly a while ago) *fake_choice did not allow any *commands under it).

That was always my understanding, @Reaperoa, but I just tested it by putting some *set commands in a *fake_choice of mine and they worked. Who knew?

Yep, *fake_choice is basically *choice now! except you aren’t forced to have any *goto after each option. I use fake_choices all the time! Very handy.

1 Like

It’s worked with *set since I’ve been using choicescript. So at least a year and a half now.

I don’t think it works exactly the same as *choice save for the *gotos though, I seem to recall there’s issues if you try to insert the *choice command into a *fake_choice but I can’t properly recall.

That makes *fake_choice pretty cool. I’m sure everyone else knew that already. The way I code in choicescript it’s like changing a lightbulb by keeping the bulb in place and turning the house.

1 Like

Hey, I’ve been having a whole new round of problems… It seems you can nest more than a certain number of *if’s in one *else, in fact there seems to be a line limit per scene. It seems that after a certain point in my code everything just stops working… Even if i put this in a different scene here is my code:

startup:

*create Syltherin 0
*create Griffindor 0
*create Hufflepuff 0
*create Ravenclaw 0
*scene_list
    startup
    tie
    end

*title SORTING HAT
*author Prof. Mitchell

Well, you've been invited to Hogwarts... Please enjoy your stay!
*page_break

So, first you must be sorted!
*line_break
Let's get started!
*page_break

You must awnser a series of questions, here is the first, A muggle comes to you and says, "GET OFF MY LAWN!!!" and has what looks like a primate non-magic sword, what do you do?

*fake_choice
    #Snarl, and slowly walk off his lawn
        *set Syltherin +1
    #Say, "Oh, I'm so sorry... I'll leave now!" and quickly get off his lawn
        *set Hufflepuff +1
    #Say, "Oh, okay."
        *set Griffindor +1
    #Make an argument on why you whould be able to be on his lawn
        *set Ravenclaw +1

2. You hear from your friend Tom that your "friend" Pete has been spreading horrible rumors about you. What do you do?
*fake_choice 
    #RUMORS?!!! Let's start spreading rumors about him and see how [i]he[/i] likes it!
        *set Syltherin +1
    #Rumors? Lemme go talk to him.
        *set Griffindor +1
    #Rumors? Whatever.
        *set Hufflepuff +1
    #Oh my, Rumors! I better get a teacher...
        *set Ravenclaw +1
    
3.You have OWL exams coming up! What do you do?
*fake_choice
    #Eh, it can wait. I'll do fine.
        *set Griffindor +1
    #Exams! Who cares about exams??
        *set Syltherin +1
    #Exams! I should help people study!
        *set Hufflepuff +1
    #Why are you telling me? I've been studing for two months!
        *set Ravenclaw +1

4.Somebody has anonymously challenged you to a duel after hours in the trophy room. Alone. What do you do?
*fake_choice
    #Go! (But make sure someone knows where I am!)
        *set Griffindor +1
    #Someone could get hurt! Of course not.
        *set Hufflepuff +1
    #WHAT?!?! That's against the rules! Better find a teacher...
        *set Ravenclaw +1
    #Go, but take two friends with me. I'm gonna pulverize this guy.
        *set Syltherin +1

5.You heard a rumor that Bob, a Syltherin, is going to do something nasty! However, you don't know what...
*fake_choice
    #Tell a teacher!
        *set Ravenclaw +1
    #Find out more.
        *set Griffindor +1
    #Someone will find out. I don't need to worry.
        *set Hufflepuff +1
    #Let him. He probably won't do it to me, so what do I care?
        *set Syltherin +1


For now this is all I am going to ask you let me calculate your scores!
*page_break

*label calculations

*if (Syltherin > Griffindor) and (Syltherin > Hufflepuff) 
    *if Syltherin > Ravenclaw
        Hmmm, I think, SYLTHERIN!!!!!!

        You finished with these scores!
        *stat_chart
            text Syltherin
            text Hufflepuff
            text Griffindor
            text Ravenclaw
        *goto_scene end
*if (Griffindor > Syltherin) and (Griffindor > Hufflepuff)
    *if Griffindor > Ravenclaw
        Well, I think, no, ummm, I think you're GRIFFINDOR!!!!!!

        You finished with these scores!
        *stat_chart
            text Syltherin
            text Hufflepuff
            text Griffindor
            text Ravenclaw
        *goto_scene end
*if (Hufflepuff > Griffindor) and (Hufflepuff > Syltherin)
    *if Hufflepuff > Ravenclaw    
        Ah, I see, you're definatly, most certainly, absoultely, certifiably, HUFFLEPUFF!!!!!!

        You finished with these scores!
        *stat_chart
            text Syltherin
            text Hufflepuff
            text Griffindor
            text Ravenclaw
        *goto_scene end
*if (Ravenclaw > Griffindor) and (Ravenclaw > Syltherin)
    *if Ravenclaw > Hufflepuff
        Well, a smart one I see, you're a RAVENCLAW!!!!!

        You finished with these scores!
        *stat_chart
            text Syltherin
            text Hufflepuff
            text Griffindor
            text Ravenclaw
        *goto_scene end
    *goto_scene end
*else
    *goto_scene tie

tie:
You have a tie! We will ask you a question with only two awnsers, pick accordingly!

*if Syltherin = Griffindor
    6. You realize you are being trailed, you have no clue who is doing this, but you are absoultly sure that this is not coincidense. What do you do? (You have all ready graduated Hogwarts and you are nearly alone in nockturn alley.)
    *choice
        #Grab a knife, but be subtle, if he comes closer, stab him and use the Reduction carm (Reducto) to shrink the body and drop it into a gutter.
            *set Syltherin +1
            *goto calculations
        #Confront him directly with your wand at his throat, preventing him from pulling out his.
            *set Griffindor +1
            *goto calculations
*if Syltherin = Hufflepuff
    6. You realize you are being trailed, you have no clue who is doing this, but you are absoultly sure that this is not coincidense. What do you do? (You have all ready graduated Hogwarts and you are nearly alone in nockturn alley.)
    *choice
        #Grab a knife, but be subtle, if he comes closer, stab him and use the Reduction carm (Reducto) to shrink the body and drop it into a gutter.
            *set Syltherin +1
            *goto calculations
        #Leave him alone, if he is trailing me, the reason probably doesn't involve killing me!
            *set Hufflepuff +1
            *goto calculations
*if Syltherin = Ravenclaw
    6. You realize you are being trailed, you have no clue who is doing this, but you are absoultly sure that this is not coincidense. What do you do? (You have all ready graduated Hogwarts and you are nearly alone in nockturn alley.)
    *choice
        #Grab a knife, but be subtle, if he comes closer, stab him and use the Reduction carm (Reducto) to shrink the body and drop it into a gutter.
            *set Syltherin +1
            *goto calculations
        #Use the Legilimens charm (mind reading & incapacitation) to weaken him then alert the Ministry of Magic.
            *set Ravenclaw +1
            *goto calculations    

*if Griffindor = Hufflepuff
    6. You realize you are being trailed, you have no clue who is doing this, but you are absoultly sure that this is not coincidense. What do you do? (You have all ready graduated Hogwarts and you are nearly alone in nockturn alley.)
    *choice
        #Confront him directly with your wand at his throat, preventing him from pulling out his.
            *set Griffindor +1
            *goto calculations
        #Leave him alone, if he is trailing me, the reason probably doesn't involve killing me!
            *set Hufflepuff +1
            *goto calculations
*if Griffindor = Ravenclaw
    6. You realize you are being trailed, you have no clue who is doing this, but you are absoultly sure that this is not coincidense. What do you do? (You have all ready graduated Hogwarts and you are nearly alone in nockturn alley.)
    *choice
        #Confront him directly with your wand at his throat, preventing him from pulling out his.
            *set Griffindor +1
            *goto calculations
        #Use the Legilimens charm (mind reading & incapacitation) to weaken him then alert the Ministry of Magic.
            *set Ravenclaw +1
            *goto calculations
*if Hufflepuff = Ravenclaw
    6. You realize you are being trailed, you have no clue who is doing this, but you are absoultly sure that this is not coincidense. What do you do? (You have all ready graduated Hogwarts and you are nearly alone in nockturn alley.)
    *choice
        #Use the Legilimens charm (mind reading & incapacitation) to weaken him then alert the Ministry of Magic.
            *set Ravenclaw +1
            *goto calculations
        #Leave him alone, if he is trailing me, the reason probably doesn't involve killing me!
            *set Hufflepuff +1
            *goto calculations

end:
*finish

There’s not a line limit per scene. (And if there was you’d be nowhere close to it with what you’ve written above).

You likely have some errors in your code that’s causing these problems. It’s not a choicescript issue. Generally if someone isn’t working it’s your coding that’s broken, not choicescript. I don’t have time to pick through it to find your mistakes but I’m sure someone else will.

I ran it through a few times one @CJW IDE tool and found no problems

https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/tools/IDE/main.html#

May need a new copy of chicescript