Branching story line


#1

I have feeling that until I thoroughly understand ChoiceScript, I will be coming back here every so often to drop a question on you guys that might seem trivial, but to me it’s puzzling to the point that I feel like a primary school kid again :stuck_out_tongue:

So the problem I have to day is that my story is pretty much determined, with set scenes that will happen no matter what the player choose, but the way they get to the point differs. The way they can get to the pre-determined scene is dependent on the race of their character and the class. Now I tried to use the *set race “blahblah”=true code and "set class “blahblah”=true code and then use *if code with and and parenthesis and even separately below one another without parenthesis and ‘and’ . But it is giving me this error message:

Error: startup line 125: invalid indent, expected at least one line in ‘if’ true block

So does anyone have an idea how I could branch off my story line so that only certain parts of the story is shown to the player depending on the race and class of the character?


#2

It would help if you posted your code to see exactly what you’re having trouble with. But based on what you’re trying to do these should work; I couldn’t tell whether you were using true/false variables or “in quotes” variables for your races and classes, so I put both.

If you’re using true/false

*if (race1 = true) and (class1 = true)
  Blahblahblah
*if (race2 = true) and (class2 = true)
  Blahblahblah

And so on for however many combinations you have.

If you’re using “in quotes”

*if (race = "race1") and (class = "class1")
  Blahblahblah
*if (race = "race2") and (class = "class2")
  Blahblahblah

And so on.

The second one would help make your created variables section less cluttered since you only have to create the two variables and then just set them to whatever you want. With the true/false, you’ll have to create a variable for every race and class you have. But you can do it whichever way works best for your story. Hope this helps! :smile:


#3

Right, I should have copy and paste the code here as it would make it much easier. Well, this is the code I am using.

    *set race "human"=true
    *set race "vampire"=true
    *set race "hekan"=true
    *set class "aristocrat"=true
    *set class "soldier"=true

A bit of general background story going on here.

*if race = "vampire"
	*if class = "aristocrat"

I also tried to use

*if (race “vampire”) and (class “aristocrat”)

But that didn’t work either.


#4

Okay, so it looks like you’re just combining two different kinds of variables. It should be either like this, if you’re doing true/false:

*create race_human false
*create race_vampire false
*create race_hekan false
*create class_aristocrat false
*create class_soldier false

Background story, and choices to select race and class. If you need any help with the choice part just let me know and I'll add it in. This is where you'll set the selected variables to true.

*if (race_vampire = true) and (class_aristocrat = true)
  Blahblahblah
*if (race_vampire = true) and (class_soldier = true)
  Blahblahblah

Or like this if you want to do “in quotes”

*create race "unknown"
*create class "unknown"

Background story, and the choices to select race and class. This is where you'll set the race to "human", "vampire", or "hekan" and the class to "aristocrat" or "soldier".

*if (race = "vampire") and (class = "aristocrat")
  Blahblahblah
*if (race = "vampire") and (class = "soldier")
  Blahblahblah

#5

Ok, I see. I am already past the race and class choices. At the top of the startup document I have exactly the same *create race “unknown” code. So do you suggest I get rid of the *set code?


#6

Actually it worked! I got rid of the *set code and it worked.

@Pangolin you are the greatest ;D


#7

To clarify, when you put something in quotes you’re telling the computer that variable is a string, aka. a series of characters, aka. text like I’m writing in now. A boolean variable is a single bit, aka. a switch that can be set to true or false. What you were trying to do in the code above was declare a string as a variable name (which is incorrect, strings and variable names are different), and then assign it true or false like it was a boolean.

That’s a little programming-oriented, so I’m sorry if I didn’t explain it in a way you could understand. If you do it’ll probably help you avoid that in the future.