Multi if statement help

So I have a game where you can many different dog breeds, including wolf nor coyote hybrids. But in my first *if statement, the human are supposed to react differently if your a hybrid vs a non hybrid.

*if (multiple hybrids listed here, don’t know how)
Human flinches.
The human shouts at you.

I don’t know how to make an *if with multiple breeds, but I would rather not do one long *if of four of those
So I don’t want this:
*if Wolfdog
human flinches
*if coydog
human flinches
human shouts

You could put them in nested parentheses, like this:

*if (((breed = "wolfdog") or (breed = "coydog")) of (breed = "other hybrid"))

Or, if you want to check this a lot, just make another variable for whether or not the dog is a hybrid, and set it true or false when you choose the breed. Then all you’d have to write is

*if dog_is_hybrid
    Human flinches
*if not (dog_is_hybrid)
    Human shouts

So I tried the first thing, with the parenthesis, but then I got this:
stray1 line 7: Invalid expression at char 95, expected no more tokens, found: CLOSE_PARENTHESIS [)]

There are 5 breeds for the *if, do I need to set a new *set code? I’m still new to this program, first time i’ve done multiple *if

Every time you add a condition, you need to add another set of parentheses around the whole thing. This is because choicescript can only process two things at a time, so you have to put everything in pairs. Honestly, it sounds like this is going to be a significant detail in your game and I’d recommend making a specific variable for it. But it is handy to know how to write if statement with multiple conditions in case you need to. 5 would look something like this:

*if (((((breed = "hybrid1") or (breed = "hybrid2")) or (breed = "hybrid3")) or (breed = "hybrid4")) or (breed = "hybrid5"))

Thanks so much! That actually worked!

If you want to use an extra variable, you’d need to create it in the startup menu with your other variables, then set it when the player chooses a breed later. So, in your startup menu: *create dog_is_hybrid false and at the choice something like:

	#Choose hybrid1
		*set breed "hybrid1"
		*set dog_is_hybrid true
	#Choose hybrid2
		*set breed "hybrid2"
		*set dog_is_hybrid true
	#Choose not a hybrid
		*set breed "something else"

Because the default setting is false, you don’t need to change it unless the player does choose a hybrid.

1 Like