Hi everyone, I’m not that good with coding and I have started to mess with the coding. The choice script is probably a lot easier for me to understand right now then the c++ coding. My question is that I had my startup file have the player choose male/female and their name. How do I carry these variables over into the next scene? I tried using an if/else statement but it seems that it does not carry over.
As long as you’re using create and not temp they should work globally. Are you remembering to set them? What’s your code look like? Could you paste it in?
*scene_list
startup
First_Chapter
variables
gosub
ending
death
*comment Default stats here
*create Leadership 20
*create Strength 30
*create Agility 20
*create Cunning 20
*create Honor 50
*create Piety 20
*create Intellegence 30
*create Valour 30
*create Nobility 20
*create name ""
*create gender "unknown"
*label gender
Before we set off on our journey into the warring states period.
We must start off with what type of person you will be.
Will you be a male or female?
*choice
#Male.
*set gender "male"
*goto nameing_prince
#Female.
*set gender "female"
*goto nameing_princess
*label nameing_prince
What will your name be my lord?
*choice
#Male name1
*finish
#Male name2
*finish
#Please enter your name.
*input_text name
Your name is ${name}, is that right?
*finish
*label nameing_princess
What will your name be my lady?
*choice
#Female name1
*finish
#Female name2
*finish
#Please enter your name.
*input_text name
Your name is ${name}, is that right?
*finish
For the next file its suppose to go something like this.
What will you do?
*choice
#Continue to the courtyard to start your training.
*if "male"
You thank the servant and continue on to your training. As you enter the stone courtyard,
your sword instructor Kouki Yoshida waiting for you to begin your lesson. "Good morning sensei,"
you say as you bow your head slightly.
"Good morning to you as well, young lord," says Yoshida as he bows his head.
Picking up two bamboo swords, your teacher toss one too you while saying,
"It is time to start your training." You continue to train by the sword until the eighth gong
was struck.
*set strength +10
*finish
*else "female"
You thank the servant and continue on to your training. As you enter the stone courtyard,
your sword instructor Kouki Yoshida waiting for you to begin your lesson. "Good morning sensei,"
you say as you bow your head slightly.
"Good morning to you as well, my lady," says Yoshida as he bows his head.
Picking up two bamboo swords, your teacher toss one too you while saying,
"It is time to start your training." You continue to train by the sword until the eighth gong
was struck.
*set strength +10
*finish
Thank you guys that worked out. I used the *if gender =“male” one. Though now I have error when I go female with it saying:
“First_chapter line: It is illegal to fall out of a *choice statement; you must *goto or finish before the end of the indented block.”
Here is the rest of the choices, starting from line 44. I can’t see whats wrong since everything looks to have the correct spacing.
#Meet with your father.
I should go greet my father in the morning. As you walk down the smooth wooden hallway,
look to your right to see the garden pond glistening in the morning light.
*choice
#Accept the terms for now.
Eventually, the barbarian westerners conquer you anyway, destroying their
bread basket, and the entire region starves.
*finish
#Threaten to salt our fields if they don't offer better terms.
They blink. Your majesty gets a fair price for wheat.
*finish
#Go into the kitchen and grab a quick meal.
I feel kind of hungry, I think I can start my training after I get a something in my stomach.
*finish
I think you forgot to add the *choice at the beginning. It should look more like this:
*choice
#Meet with your father.
I should go greet my father in the morning. As you walk down the smooth wooden hallway, look to your right to see the garden pond glistening in the morning light.
*choice
#Accept the terms for now.
Eventually, the barbarian westerners conquer you anyway, destroying their bread basket, and the entire region starves.
*finish
#Threaten to salt our fields if they don't offer better terms.
They blink. Your majesty gets a fair price for wheat.
*finish
#Go into the kitchen and grab a quick meal.
I feel kind of hungry, I think I can start my training after I get a something in my stomach.
*finish
Well its all one big block of choices, I have have 3 options. Here is the block in full.
Also thank you for responding once again FairyGodfeather and fanton.
What will you do?
*choice
#Continue to the courtyard to start your training.
*if gender ="male"
You thank the servant and continue on to your training. As you enter the stone courtyard,
your sword instructor Kouki Yoshida waiting for you to begin your lesson. "Good morning sensei,"
you say as you bow your head slightly.
"Good morning to you as well, young lord," says Yoshida as he bows his head.
Picking up two bamboo swords, your teacher toss one too you while saying,
"It is time to start your training." You continue to train by the sword until the eighth gong
was struck.
*set strength +10
*finish
*else gender ="female"
You thank the servant and continue on to your training. As you enter the stone courtyard,
your sword instructor Kouki Yoshida waiting for you to begin your lesson. "Good morning sensei,"
you say as you bow your head slightly.
"Good morning to you as well, my lady," says Yoshida as he bows his head.
Picking up two bamboo swords, your teacher toss one too you while saying,
"It is time to start your training." You continue to train by the sword until the eighth gong
was struck.
*set strength +10
*finish
#Meet with your father.
I should go greet my father in the morning. As you walk down the smooth wooden hallway,
look to your right to see the garden pond glistening in the morning light.
*choice
#Accept the terms for now.
Eventually, the barbarian westerners conquer you anyway, destroying their
bread basket, and the entire region starves.
*finish
#Threaten to salt our fields if they don't offer better terms.
They blink. Your majesty gets a fair price for wheat.
*finish
#Go into the kitchen and grab a quick meal.
I feel kind of hungry, I think I can start my training after I get a something in my stomach.
*finish
You don’t need the ‘gender = “female”’ after the *else.
Another thing I see is that instead of using *if statements you could just create a variable for “young lord” and “my lady”.
Is it a quicktest error? I think the easiest way to get around it is move the *choice under “meet with your father” out of there.
*choice
#Meet with your father.
I should go greet my father in the morning. As you walk down the smooth wooden hallway, look to your right to see the garden pond glistening in the morning light.
*goto labelname
*label labelname
*choice
#Accept the terms for now.
Eventually, the barbarian westerners conquer you anyway, destroying their bread basket, and the entire region starves.
*finish
#Threaten to salt our fields if they don't offer better terms.
They blink. Your majesty gets a fair price for wheat.
*finish
I’m not getting an error, but when I copied your code I had to reformat it because it pasted weird for some reason. Here’s what I have:
*create gender “male”
*create strength 10
What will you do?
*choice
#Continue to the courtyard to start your training.
*if gender ="male"
You thank the servant and continue on to your training. As you enter the stone courtyard, your sword instructor Kouki Yoshida waiting for you to begin your lesson. "Good morning sensei," you say as you bow your head slightly.
"Good morning to you as well, young lord," says Yoshida as he bows his head. Picking up two bamboo swords, your teacher toss one too you while saying, "It is time to start your training." You continue to train by the sword until the eighth gong was struck.
*set strength +10
*finish
*else gender ="female"
You thank the servant and continue on to your training. As you enter the stone courtyard, your sword instructor Kouki Yoshida waiting for you to begin your lesson. "Good morning sensei," you say as you bow your head slightly.
"Good morning to you as well, my lady," says Yoshida as he bows his head. Picking up two bamboo swords, your teacher toss one too you while saying, "It is time to start your training." You continue to train by the sword until the eighth gong was struck.
*set strength +10
*finish
#Meet with your father.
I should go greet my father in the morning. As you walk down the smooth wooden hallway, look to your right to see the garden pond glistening in the morning light.
*choice
#Accept the terms for now.
Eventually, the barbarian westerners conquer you anyway, destroying their bread basket, and the entire region starves.
*finish
#Threaten to salt our fields if they don't offer better terms.
They blink. Your majesty gets a fair price for wheat.
*finish
#Go into the kitchen and grab a quick meal.
I feel kind of hungry, I think I can start my training after I get a something in my stomach.
*finish
Ok, I got it work finally. I still don’t know why it did not work but I had to use a work around as suggested by seabean. THANK YOU!
fantom I tried copying what you put and that gave me a different error message, so I had to revert back. I think the code hates me.
I also had to move the kitchen option to second choice and that seemed to work. Ran through the male/female roles and names and all looks good. Thank you everyone for the help. I’ve tried coding before and forgot how much it sucks to have an error message and it works fine for other people but not for you.
As a matter of curiosity, are you familiar with outlining? I mean, taught in highschool- the rules and indentations? Like, if you have a 1, you must have a 2, if you have an A, you must have a B? Choice Script is a lot like creating an outline, with a teacher that will give you an error message if you don’t follow the rules, instead of a red mark. You need to have things properly aligned, can’t forget the proper format, and are expected to look up yourself how to do this from the textbook. That’s one way to look at it, in any case…
From what you posted above, usually your formatting is off just a little. Like you hadn’t lined up your choices with the last code section you posted.
Thanks for the comments. Some of the stuff I was using just notepad before switching to notepad++ so some of it might be misaligned. I’ll try to be careful on how things are aligned in the future. I’ve heard that there is an add-on for notepad++ for this type of script, do any of you know the name of this add-on?
On a separate note, can you use if/else statements within if/else statements underneath an #option?
The add-on for notepad++ is a syntax highlighter, and the instructions for downloading and installing it can be found here. As for your second question, you can nest *if/*else statements and *choice statements one after the other almost endlessly as long as you maintain proper indentation. However, the more you nest your statements the more complicated your code is, and the more difficult it makes to track down problems with your code. It’s generally recommended that you only nest a handful of statements deep, with the actual amount depending on what you feel you can comfortably keep track of. If you find you’re needing to do a particularly complicated bit of code that might require you to nest statements deeper, I’d recommend using *goto and *label statements instead to flatten it out a bit and make it easier to read.
@Wakabam45 Yes. Also, something I didn’t know right away but found out later which really, really helped, is that if you use *if statements without using *elseif / *else, it acts like a *false_choice, and continues on the same indentation line after the *if statements (or if they are skipped). If you use *else, though, you need to use a *goto at the end. Just using *if, you do not need to. And you can include *if statements inside *if statements.