Need help displaying different text in scenes using boolean type data variable

you can choose different paths in the game and in the first scene after you have chosen who to play as, i need to display slightly different variations of the text. I can’t find a way to do this. I tried coding it like:

general text

*if (var)
text text text
*else if (var2)
TEXT TEXT TEXT

It did not work so i tried to redirect it to different scenes like firstvar andfirstvar2 like this:

*choice
#surname
*set Surname “surname”
*if (var)
*goto_scene firstvar
*if (var2)
*goto_scene firstvar2

firstvar and firstvar2 had different texts, but this did not work and always directed me to the firstvar. I tried doing it like this as well but same result:

*choice
#surname
*set Surname “surname”
*if (var)
*goto_scene firstvar
*elseif (var2)
*goto_scene firstvar2

Is there any way to do what I’m trying to do?

*create charA false
*create charB false
*create charC false

*set charB true

*if (charA)
  Text for A
*elseif (charB)
  Text for B
*else
  Text for C

In this case it shows “Text for B” when I tried it.
Is this what you want to accomplish?
If charA is ever set to true and then not set to false when charB is set to true, this if/else block will still always display “Text for A”. But I don’t know what’s really happening in the not-working code without seeing all of them.

2 Likes

Did you make sure to start the boolean’s off as false? When using an if, elseif, else statement the first boolean that is ‘true’ will be chosen first.

Also, your first example should be

*if (var)
    Text A
*else
    Text B

You use elseif (always one word btw) only if there is three or more things. If there is only two, just use if and else.

1 Like

@ FoxalypticWorld
So I finally figured it out and i went with the redirection to different scenes in the first scene with the general text, nothing else worked, i’m afraid :woman_shrugging:

Could you provide a picture or type out what you have changed since your original post?

Here’s what I do.
Make sure to create variables in the startup.txt or make temp variables in the same scene as the if commands.

*create 1 false
*create 2 false
*create 3 false

*set 2 true

*if 1 true 
    Text here.
*if 2 true 
    Text here.
*if 3 true
    Text here.

This would also allow you to have two variables true at the same time and have the text combine with each other.

1 Like

This is what i did:
*choice
#text
text
*if (var)
*goto_scene firstvar
*else
*goto_scene firstvar2

Also, i create these variables with true, instead of false like you do, so its like

*create var true

and then

#choice for character goes here
*set var true

Should i do it like you?

Yes those varibale need to be False in the beginning or they will pass the first check.
also can you post in preformated text so we can see indents.
Just select your code and select the </> option in box.

Always create variables that are false, then set them to true when you need to.

Also, make sure to add *if var true.

1 Like

I tested the game numerous times with the variables created as true as they are now for other things and they have worked so far.

If you create variables as true they will pass the first *if automatically and won’t check any *elseif.

2 Likes

When you create a variable false, the *set Command can set it to true only when you need it to pass an *if Command.

Setting it to true when it is already true is redundant.

1 Like

oh okay, i’ll keep that in mind :+1:

Ah, sorry. I must not have made myself clear in my last message. When I asked if you set your variable to true when you made them, that’s why.

The first *if statement with a true variable will be the one that runs. So you want to always create your variables as false and only set them to true when they become relevant in the story. Otherwise, you’ll run into situations like this.

1 Like