Having trouble with condition coding

i’m new to choice script and there is a problem i’m having right now and it doesn’t look like i will be be able to solve it on my own, so i decided to ask help here.

the coding looks like this:

“excuse me sir would please be so kind to spare a coin to a poor old dwarve?”

*if race = “Demon”
"Excuse me sir would ple-… the dwarve stopped his words his words and had his eyes fixated on me for a moment before his face turned into one of complete fear and terror.

what is the problem? well, only the bottom text is supposed to show in case you are using the specific “Demon” race but it is showing the top text as well which is supposed to be shown only for races beside “Demon”. but nothing i do works to fix this problem.

Hey there, I’m not sure if I understand your question, but everything below *if is what should show if “Demon” is your race. Try indenting it like this?

“excuse me sir would please be so kind to spare a coin to a poor old dwarve?”

*if race = "Demon"
  "Excuse me sir would ple-… the dwarve stopped his words his words and had his eyes fixated on me for a moment before his face turned into one of complete fear and terror.

And if you keep having trouble, you can run quickest and see what errors come up. It’s easier to fix issues that way.

1 Like

You need to add a condition to prevent the first text from showing up if the second one is triggered. I think what you want is something like:

*if race = “Demon”
     "Excuse me sir would ple-… the dwarve stopped his words his words and had his eyes fixated on me for a moment before his face turned into one of complete fear and terror.

*else
     “excuse me sir would please be so kind to spare a coin to a poor old dwarve?”

So it will first check to see if the player is a Demon and show the Demon specific text if so, and if not it will show the other text instead.

3 Likes

it looks like this in game:


and that first part is not supposed to show up
i tried identing it like you said but it din’t work

You can keep Identation by using these ```. It would look like this:

*if race = "Demon"
  "Excuse me sir would ple-… the dwarve stopped his words his words and had his eyes fixated on me for a moment before his face turned into one of complete fear and terror.

*else
  “excuse me sir would please be so kind to spare a coin to a poor old dwarve?”

@daniel_santos Does this work?

2 Likes

Ah, thanks. I guess I don’t have all the formatting tricks here figured out yet.

2 Likes

Hi @SilentOne, thanks for reaching out about this issue! If a specific post solved your problem, please mark it with the green Solution checkbox (tap/click the ellipsis on the bottom of the post and select the checkbox from there) so other users with similar problems can find the solution easier. :slight_smile:

You could also use
* if race != "Demon"

(!= means “inequal to” in coding language) Instead of *else, if you don’t want to have to create a label to get back to the next part of the text.
(IIRC. It’s been a while since I last played around with ChoiceScript)
This method a little more sensitive to errors.

Edit: forgot how to format things on the forum. Anyone who can point me in the right direction?

Edit 2: Figured it out

5 Likes

i tried it and now the game crashes regardless of what race i choose…

Try adding some “non-if” text before the *if (normal, plain text). If it keeps not working, could you screenshot the error and send it here?

oh nvm, i was just doing it wrong and now it works THANKS!

1 Like

though the else command makes it crash so i had to use @Cecilia_Rosewood tip to amke it work

1 Like

What happens when you use the *else command and how are you using it?

when i use the else command the game just crash whenever i pick a race besides “Demon”

Yes and what is the error message and how are you using the command?

i keep getting either “non existent variable “else”” “or it is illegal to fall out of a choice statement”

i’m sending the screen shot

Its just *else, not *if else. The other error is expected, ChoiceScript has a requirement that you must add a *goto at the end of every *else for some reason, even if it’s to go to a label right underneath it.

*if race = "Demon"
     "Excuse me sir would you ple-...
     *goto afterif
*else
     "Excuse me sir would you please be so kind...
     *goto afterif

*label afterif

Continue here...

Either you need to do that, or activate implicit control flow to disable this requirement:

1 Like

i’m still getting the “it is illegal blablabla” and don’t know what i’m doing wrong this time…