Help with setting a variable when a choice is made and making another choice return to another choice


#1

Hello everyone,
Recently I started messing around with ChoiceScript, and I’ve got the following code:
You’re legs are pumping, it’s 30 below zero, and you’ve just killed your first Zombie. Evidence of this can be clearly scene, it’s brains smeared all over a baseball bat you found a ways back. Strength is not your greatest asset, however. You are surrounded, and you know that for every Zombie you take down with a bash of the bat, more are right behind, and more importantly, in front of you. Having been exiled from New Canton, you must find your own way in this hellish world.

*set strength +7

*choice
#This Runner 5 is a warrior: Try to fight and collect as much as you can hold.

    Preferring the brave fighter approach, you raise your baseball bat in a two-handed grip, and smash anything, especially heads, that come in contact with it. Speed is still winning over your strength, but your legs are really starting to tire from such a long run. New Canton sent you with only bread and water for sustance, anything else you had to find on the way and that's not very much.

As the never-ending hored of Zombies approach you, you feel the need to break away from this fight, else you slow down and die.
*choice
#Turn back and head in the direction of New Canton.
You know you can’t head back to New Canton so soon. You know they wouldn’t simply let you back in, even though the reason they exiled you was because you didn’t like Major De Santa’s strict rules. With a birst of speed, you turn around, circling around away from the approaching Zombie horeds. Slowing down, you observe the area around you.
*choice
#Head east to what looks like an abandoned building.
At a fast walk now, you head east to a building in the distance. The constant Zombie growling reminds you why you regret not sticking to the major’s plans. You’re alone, and that could cost you your life. Worse, this is late, when Abel Township would certainly not raise their gates for a person they wouldn’t have the utmost trust for. No, this Runner 5 is a loner. Hopefully not for long, though.
Should you investigate Abel Township more, or forge your own path?
*choice
#Alone, scared, and surrounded by more than one Zombie hored? Do whatever it takes to get into Abel.
This choice under construction.
*finish
#This Runner 5 is cunning: Sneak around the zombs.
Since these Zombies are as slow as a turtle, it isn’t hard for you at all to sneak away from them. Since you are alone, you have only yourself and the fridgad wind distracting the Zombies enough so that you can quietly walk away. They happily ignore you as you go on your merry way. What to do now…

I’ll fix typos later. I get an error when I select the fight option. Also, the sneak option is not present, and I’m trying to figure out why. I think I know what the error for the fight option is for, but if I put it under *choice, I get an error telling me that the language expects choice body. So where can I put the code to raise Strength by seven for the fight option?
Also, I’m trying to figure out how to go back to the “turn back and head to New Canton” choice when selecting the cunning option. It’s supposed to say that I sneak away, then give me the options for either trying Abel or going alone, though I didn’t make that second option available yet.
Thanks for any help, this is my first time with Choicescript.


#2

You’ve pasted in the code wrong. If you paste it in again, highlight the code section and hit the </> button it should display your code properly.

Choicescript works on indents. We can’t see yours in the above example so it’s hard to help you fix things. Also your formatting makes it a bit tough for me to read your questions at the end too.

Have you checked out the wiki?


#3

Apologies if you have already solved the issue, but here is what I believe, from what information I can see, is the issue:

The problem you have doesn’t appear to be indentation. The issue is that you haven’t sent the player anywhere else after selecting a choice. You must either use the *goto command, a *choice command or the *finish command after each choice for it to work. An example for the fight choice:

    Dialogue
    *set strength +7
    *choice
      #This Runner 5 is a warrior: Try to fight and collect as much as you can hold.
        Put the dialogue here.
        *goto name_of_label_here

*label name_of_label_here
More dialogue.

Of course, you’d have to insert and name everything yourself, but that structure would work. As long as you do it for each and every choice and either send them to the same label or to a different one, then it should all work.

Now, if you have choices within choices, then the problem may well be indentation or bad labelling. I cannot tell unless you describe the error. Like FairyGodfeather said, please do read the wiki first.


#4

@BlazedStorm There is actually indentation there. Orinks just hasn’t clicked the right buttons so we can see it on the forums. While normally I’d fix that myself there’s something weird going on in the post so I can’t do so easily. I’m also a little confused with the questions.

I think it’s indented as (but even this isn’t showing up everything correctly).

Your legs are pumping, it's 30 below zero, and you've just killed your first Zombie. Evidence of this can be clearly scene, it's brains smeared all over a baseball bat you found a ways back. Strength is not your greatest asset, however. You are surrounded, and you know that for every Zombie you take down with a bash of the bat, more are right behind, and more importantly, in front of you. Having been exiled from New Canton, you must find your own way in this hellish world.

*set strength +7

*choice
    #This Runner 5 is a warrior: Try to fight and collect as much as you can hold.

        Preferring the brave fighter approach, you raise your baseball bat in a two-handed grip, and smash anything, especially heads, that come in contact with it. Speed is still winning over your strength, but your legs are really starting to tire from such a long run. New Canton sent you with only bread and water for sustance, anything else you had to find on the way and that's not very much.
As the never-ending hored of Zombies approach you, you feel the need to break away from this fight, else you slow down and die.
*choice
    #Turn back and head in the direction of New Canton.
        You know you can't head back to New Canton so soon. You know they wouldn't simply let you back in, even though the reason they exiled you was because you didn't like Major De Santa's strict rules. With a birst of speed, you turn around, circling around away from the approaching Zombie horeds. Slowing down, you observe the area around you.
*choice
    #Head east to what looks like an abandoned building.
        At a fast walk now, you head east to a building in the distance. The constant Zombie growling reminds you why you regret not sticking to the major's plans. You're alone, and that could cost you your life. Worse, this is late, when Abel Township would certainly not raise their gates for a person they wouldn't have the utmost trust for. No, this Runner 5 is a loner. Hopefully not for long, though.
Should you investigate Abel Township more, or forge your own path?
*choice
    #Alone, scared, and surrounded by more than one Zombie hored? Do whatever it takes to get into Abel.
        This choice under construction.
*finish
    #This Runner 5 is cunning: Sneak around the zombs.
        Since these Zombies are as slow as a turtle, it isn't hard for you at all to sneak away from them. Since you are alone, you have only yourself and the fridgad wind distracting the Zombies enough so that you can quietly walk away. They happily ignore you as you go on your merry way. What to do now...

#5

@FairyGodfeather I see. From what is shown there, @Orinks may have used the *choice command at every selectable option instead of nestling them together under the one *choice. If that’s the case, then the error he/she is receiving would be because there is no indication of what to do after selecting an option (i.e *goto , *finish)

@Orinks if you could describe the error you keep getting then we could at least pin point the issue and make sense out of it all.


#6

@BlazedStorm Aha! That may be the issue.


#7

Hi everyone,
Thanks for the help. As for formatting, I’m using the default formatting provided by the forums–I usually don’t mess with that stuff since I’m using a screen reader.
I’m not getting an error, but only the fight option is showing up and not the cunning option. I’ve started at the wiki actually, and used the example provided in the ChoiceScript download about animals and such. I deleted that content and put my code in place of it, so I no longer have it. I’m sure the wiki has some good examples I’ll take a look at. The thing I’ve noticed is that that particular example did not label everything, but I’m just going from memory.
I wish the CS Ide was accessible to me. Hopefully in the next version.