Tara explains: Ifs, elses, gains, labels, gotos and the points system!

Author: Tara Star (TaraStar on the Forums, tarastarofficial on Instagram)

Hi everyone! Me again :blush: today I’m going to go through some of the more advanced features of the Script Writer, and hopefully explain them clearly. Before reading on, I advise that you familiarise yourself with the advanced directing guide before hand, and you should at least have a knowledge of basic choices.

Labels and gotos

Before I talk about if/else systems, you need to be familiar with how to use labels and gotos. It’s a lot easier than it sounds. Essentially, a label is when you basically “name” part of the script and mark it out. Then, later on you can use a goto and this will allow you to return to the label you set up earlier, because the Script Writer then recognises that you “named” this part of the script earlier. It’s easier for me to show you what I mean. Let’s say we’re doing a choice scene.

choice
“Go to the park!”{

}”Go to the swimming pool!”{

}

That looks simple enough. But then, how would you be able to let the reader go to the scene of their choice? If it’s only a short scene, you could add the scene into the choice branch. But then, you can’t have labels and dressing games in a choice. So, you could use labels and gotos:

choice
“Go to the park!”{
goto park_play
}”Go to the swimming pool!”{
goto pool_play
}

After using the goto command, you would then underneath the choice have to have this:

label park_play
#your scene and dialogue here, however long you want the scene to be

goto end_play

label pool_play
#your scene and dialogue here, however long you want the scene to be

goto end_play

After using this code, you would then need to create a label end_play then underneath continue writing your story (this is where the two activities would merge to after the scene has been completed). It looks a bit confusing, but then if you follow the labels and gotos you should be able to make sense of what the reader will see if they select option A or option B. It’s a bit tricky to explain, but just try some experimenting!

If & else

In a different article, I’ve written about how you can let the reader choose their gender. However, for more complicated things like that, you need to be confident using if and elses. So, what are they? Well, it’s a system where you can either refer to previous choices or previous typed in choices and then depending on what the reader chose/entered you can cause different things to happen. Let’s take some examples.

Let’s say that in a story, you’re letting the reader choose a name, but you don’t want them to be able to call their character “Tara” because i.e. Tara is another pre-made character. How would you ensure they don’t enter that name, then? Well, first you would have the naming input code:

label first_name_input
input What’s Your First Name?|What’s Your First Name?|Done(NAMEF)
if (NAMEF is “”) {
AUTHOR (talk_think)
You do need a name.
goto first_name_input

} else {
continue
}

If you look at that which I’ve edited slightly from the Avatar script templates, you can see it already uses an if and else scenario to ensure that the Reader does enter a name. So now, you could just add in another line and then your code would look like this:

label first_name_input
input What’s Your First Name?|What’s Your First Name?|Done(NAMEF)
if (NAMEF is “”) {
AUTHOR (talk_think)
You do need a name.
goto first_name_input
}if (NAMEF is “Tara”) {
NARRATOR
The name Tara cannot be entered. Please choose a different name.
goto first_name_input
} else {
continue
}

Hopefully, if you follow the code you can see that if the reader entered Tara then an error message would come back and it would go back to the start of the label where they can then re-enter their name. If you want to see how to use if/elses from a non type-in choice, see my article on letting the reader choose their gender.

Gains

Okay. Let’s say you’re creating a mini game where the reader needs to find some magic dust. The easiest thing to do would be this: create a choice.

choice

“Search here!” {
goto search_here

}”Search left!”{
goto search_left

}”Search right!”{
goto search_right

}”I’ve found it!”{
goto done_search

}

The choice above, using gotos, would then require you to create three labels and then at the end of each you section you could do this:

label search_here

NARRATOR
Something happens in the mini game.

gain magic_dust

After creating these labels for each of the options, you would then have to create a final label for the “I’ve found it!” (or e.g. “Done” or “Finished”) for example:

label done_search

@YOU walks to screen center

if (magic_dust){

goto finished_search

} else {

NARRATOR
You haven’t found the item yet.

}

So, the above code would then allow the reader to go to a label called finished search (where you would continue the story) if they’ve found the item (in this case, magic dust) but if they haven’t found the item then you could use a goto and link it back to the start of the minigame.

If you haven’t come across gains before, this is probably a bit daunting to understand, so I suggest you read through this section again However, essentially gains are really useful as in a mini game they can be used in coding to show that the reader has collected something. Gains therefore can be used like in the example above so that the reader can’t continue until they’ve found something. In addition, in e.g. a mystery story you could use gain_photo and have different gains for pieces of evidence, then at the end you could use the if coding demonstrated above so that the reader only solves the mystery if they have collected e.g. two specific pieces of evidence. Alternatively though, if you were creating a mystery game and didn’t mind what the evidence was as long as the reader had found e.g. any 2 out of 5 pieces of evidence, you could then use the points system…

Points system

I won’t lie – using the points system takes a while to get the hang of. But, it can be really useful and save you so much time!

So, let’s say you’re making a minigame, where the reader has to answer 5 questions, and the pass mark is 3/5. You’re original thoughts might be to use gains – for example:

NARRATOR
What is Episode?

choice
“A TV program!”{

NARRATOR
Incorrect!

}”A place!”{

NARRATOR
Incorrect!

}”An app!”{

NARRATOR
Correct!

gain question_one

}

Then, you would use if/else to determine at the end whether the reader had scored more than 3. However, what if the reader got Q1, 4 & 5 correct? Or Q2, 3 & 4 correct? You would have to do an awful lot of coding! So, the better alternative: using points! You’d just do this for each question:

NARRATOR
What is Episode?

choice
“A TV program!”{

NARRATOR
Incorrect!

}”A place!”{

NARRATOR
Incorrect!

}”An app!”{

NARRATOR
Correct!

@YOU +1

}

Now, you may be thinking, how does this save time? How is it easier that using gains? Well, unlike if you use gains, rather than having to use a lot of if/else codes at the end of the minigame, you could instead just do:

if (YOU > 3){

NARRATOR
Well done! You passed the quiz!

}else{

NARRATOR
You didn’t pass the quiz…too bad!

}

So, hopefully this demonstrates how the points system can be really useful! If you need more help, as always feel free to contact me but there’s also some really good tips in the guides so check them out! I hope this helps you all :blush:

119 Likes

Where do you get the energy to write so much? :see_no_evil:
I like your explanation! :heart:

I also mix if/elif with named choices and points.:heart:

8 Likes

Ifs are for me like list :smiley:

10 Likes

Thank you this would help me so much!

1 Like

Thank you so much! :heart:

Haha, I don’t know! I guess I love writing, whatever the type, and even though I prefer fiction, I’ve actually had to do a fair bit of non-fiction writing over the years, so I guess I just… write. I don’t write articles often though, so when I write them, I try and write them on topics that I think are commonly misunderstood, or that are tricky, and I write in a lot of detail to try and make things really clear and easy to follow. That’s my aim, because I want to help as many people as possible!

I love how you’ve mixed them! To be honest, there are so many things you can do with if/elses, gotos, gains, labels, and points. If (no pun intended) I’m honest, I actually have never used elifs (gasp!) because… I just don’t like them I think? I much prefer using labels, gotos, ifs and elses rather than points, gains and elifs… but, if you understand them and are confident using them, that’s awesome because it will open up a lot of possibilities in your writing.

Keep experimenting! xx

5 Likes

That’s such a logical way of thinking about it… I never really plan my branching at all, so I just make everything up, but looking at it like a list is really smart! Great idea! xx

No problem! I’m so glad you found this helpful, and please feel free to let me know if you need a hand with any of this coding in the future! xx

Ok!

2 Likes

Hey, I have a question :sweat_smile:
For the points system, does the character who receives the point need to be in the scene?
Thanks! <3

3 Likes

Hi there! I actually don’t use points a lot, but I believe that the person doesn’t need to be in the scene. What I’d do is, assume they don’t need to be in the scene, code as normal, and then test it. If the character pops up or something goes wrong, to be on the safe side just add them in off screen:

@CHARACTER spot 1.28 -1000 0 in zone 1

That will make sure that they don’t pop up at all. So, to summarise, just test it and place your characters off screen as necessary. But, I think that you don’t need to have the character in the scene! :slight_smile:

1 Like

Okay, thank you so much! I’ve been using points in my story for a long time now, and I was worried that I might’ve been doing things wrong because I read another older post about the characters being in the scene. Thanks again <3

1 Like

Hi there, I’m really gratefull for your explaiation but what do I do with ifs, elifs and elses when I have more then 3 options. let’s say I have a dress up game where I let the reader pickout one of 4 outfits, and I change the cene What do I do then?

1 Like

It’s just to remember previous choices. For example if you made an outfit choice and you want another CHAR to comment on it, or if you want to have your reader choose a romantic partner amongst 2 or more, then you want the decision to be consistent in the next chapters. Using if/elif/else will help make that happen.

2 Likes

If you want her to keep running around with the same outfit she chose forever, she will. You don’t need if/elif/else to keep the outfit. But, for example, if she was choosing between a white, a black or a pink outfit, and you want another CHAR to mention the color she chose, then that’s when you’d need the if/elif/else.

2 Likes

No problem at all, I was new once lol, it’s tough

3 Likes

Ohhh! Thank you so much!!!

1 Like

But how about the names then, I mean if you want the reader to choose a name but not one of your own char’s scripted names. And in my case that certainly is more then 3, so what do you do then?

1 Like

Well when you can put up a warning using a NARRATOR bubble, asking them not to choose whatever names you have already given your characters. I’ve seen that before on other stories

1 Like

I guess I’ll do that then… Thank you again! haha

1 Like

Yea sorry there’s no way of excluded names. :blue_heart:

image

1 Like