Having trouble with condition coding

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…

You are adding choice options without using a *choice. Remove all #test and #test 2 from the code otherwise it will not funcionar_caralho.

Choice options (those starting with #) are only used after a *choice or *fake_choice so they will not work here.

2 Likes

now it is like that “else” variable don’t exist because the same thing is being showed to every race


Boy…this is starting to stress me out.

Now your indentation is messed up. Things need to be indented correctly (by the same level for each command that has sub-commands) for it to work.

Here is an example:

So your code should look like this:

*if race = "Demon"
	"Excuse me sir would you ple-...
	*fake_choice
		#test
			"test"
			*goto funciona_caralho
		#test 2
			"test
			*goto funciona_caralho
*else
	"Excuse me sir would you ple-se be so kind...
	*fake_choice
		#test
			"test"
			*goto funciona_caralho
		#test 2
			"test"
			*goto funciona_caralho

*label funciona_caralho

test text

You should start slow and take some time with the basic tutorial for choicescript.

1 Like

you are right, better focus on tutorials for now, i knew coding wasn’t easy but damm. anyway thanks for your help.

2 Likes

Nice to see the problem was solved :slight_smile: