Narration change based on variables

Hello all.

So, looking at the games on this site, it’s evident that the narration can be altered to include some things (like the “Clotho nostalgia” in Choice of the Vampire, if she was your love interest). However, I have no idea how to go about doing this.

I’ve done simple things with “if” and “elseif” commands in ChoiceScript before, but this seems more complicated. What I’m really talking about is your character meets someone, and depending on what elemental type you are, the meeting is different.

Thanks!

Do it with boolean variables. For example, you may meet someone in a game named Jack. If you meet Jack, a variable (jack_met) is set to true. Then I have some other variable track whether or not Jack is a friend (jack_friend). Here’s the code.

*temp jack_met
*set jack_met false
*temp jack_friend
*set jack_friend false

*label Jack
You spot a man at the bus stop.
*choice
#Introduce myself
*set jack_met true
*goto TalkToJack
#Pass him by
*finish

*label
“Hello, I am ${name}.”

The man smiles.

“I am Jack. Would you like to be friends?”
*choice
#Yes
*set jack_friend true
*finish
#No
*finish

There is no trick to it, other than just adding more variables, then actually making use of them. It really is just about adding complexity. Remember: Complexity which adds to the game, making it better, is good, while complexity which does not is bad.

For example lets take JimD’s code and expand on it. ( @JimD , sorry for ripping your example, but I thought it needed to be expanded. :p) Let’s say we want Jack to get assassinated. Now, we’re going to give you the chance to meet him, just like like JimD wrote, then we’re going to have some space in between the scenes (where other things happen), then we’re going to use our variables in another scene, where we actually kill Jack. Comments (to inform you of what exactly we’re doing) will be in *comments and highlighted.

What is your name? *input_text name *commentThis is just so that you can type in your name`.

*temp jack_met
*set jack_met false
*temp jack_friend
*set jack_friend false
*comment These variables can be (and should be if they are to be used in different scenes) set in the mygame.js file.

*label at_bus_stop
*comment We're not using this label, it's just here so you can see where we start.
You spot a man at the bus stop.
*choice
#Introduce yourself.
*set jack_met true
*goto talk_to_jack
#Don’t talk to him.
*goto get_on_bus

*label talk_to_jack
You say, “Hello, I am ${Name}.”

The man smiles and says, “I am Jack. Would you like to be friends?”
*choice
#Yes
*set jack_friend true
*goto get_on_bus
#No
*goto get_on_bus

*label get_on_bus
The bus pulls up and you both get on.
*comment Now you'd have other scenes in here, but we're going to skip to the scene where Jack dies.

*label jack_dies
You see
*if jack_met = true
Jack.
*if else
that man that you saw at the bus stop earlier.
*comment Here we change what you see based on whether you met Jack.

Suddenly, he is shot. You run up to him.
*if jack_friend = true
He says, “Thank you, {Name}, for being here when I die, my friend." *elseif met_jack = true He says, "I'm sorry we were never friends, {Name}.”
*else
He says, “I should have said hello to you at that bus stop, stranger.”
With that, he dies.
*ending
`

(Note that that is a fully functional code. You can slap it into a choicescript scene and actually play it to see how it works in action.)

Now, as for what you mentioned about wanting the scene to play out differently based on what element the player chooses, it’s just a matter of finding what you want to play out differently based on previous choices, then making it play out differently with *if commands. I hope that helps.

tl;dr No tricks, just use lots of *if commands.

Thank you! That’s immensely helpful. And I was thinking it couldn’t possibly be that simple.

Poor Jack.

lol, Jack died. :smiley: