*if with a choice

I’m having trouble with…

The error I’m getting is:…

My code looks like this:

*fake_choice
  *if ((LangNisai = 1) and (Nisai =< 3)) and (Sexuality != 4) and (Spoken = 0))
    *hide_reuse #"Sings with Winds, you find me attractive?" I say in fluent Nisanese.
      "I... uh... it wasn't... erm..." Sings with Winds stutters as she looks anywhere in the room other than your face while small whirlpools form in the liquid that make up her body.
      
      "Well, go on, sister. Tell the director." Walks with Winds teases from her spot on the couch as she glances up from her terminal as she experiences a few small involuntary contractions in her membrane. 
      
      "Erm... it must be an error in translation. Or perhaps the director misheard me." Sings with Winds stammers. "We have work to do! We should definitely save this conversation for another time. Instead of now. Now is too important. Was there something you needed, director?" she changes the topic as she forces herself to appear normal once again. 
      *set Sings %+ 10
      *set NisaiSpeak 1
      *goto SistersConvo

I remember there being some kind of trick with multiple variables involving the parenthesis though I can’t remember how to get around this part.

I am currently trying to use this:

*fake_choice
  *if ((((LangNisai = 1) and (Nisai =< 3)) and (Sexuality != 4)) and (Spoken = 0))
    *hide_reuse #"Sings with Winds, you find me attractive?" I say in fluent Nisanese. 
      "I... uh... it wasn't... erm..." Sings with Winds stutters as she looks anywhere in the room other than your face while small whirlpools form in the liquid that make up her body. 
      
      "Well, go on, sister. Tell the director." Walks with Winds teases from her spot on the couch as she glances up from her terminal as she experiences a few small involuntary contractions in her membrane. 
      
      "Erm... it must be an error in translation. Or perhaps the director misheard me." Sings with Winds stammers. "We have work to do! We should definitely save this conversation for another time. Instead of now. Now is too important. Was there something you needed, director?" she changes the topic as she forces herself to appear normal once again. 
      *set Sings %+ 10
      *set NisaiSpeak 1
      *goto SistersConvo

The part I need help with is getting all four of those variables to be required for the option to be available but the error says c1 line 1170: Invalid expression at char 32, expected NUMBER, STRING, VAR or PARENTHETICAL, was: INEQUALITY [<

The wiki says:

Multiple conditions can also be checked, which require more parentheses to separate them:

Three equations: *if (((var1 > 10) and (var2 > 20)) and (var3 > 30))

Is var1 greater than 10 and var2 greater than 20 and var3 greater than 30? Note that each and/or can only connect two equations, and each equation can only be connected to one and/or. For example:

On this page: If | ChoiceScript Wiki | Fandom

Update:

Also tried this and didn’t get anywhere with it.

*fake_choice
  *if ((((LangNisai = 1) and (Nisai =< 3))) and (Sexuality != 4))) and (Spoken = 0)))
    *hide_reuse #"Sings with Winds, you find me attractive?" I say in fluent Nisanese. 
      "I... uh... it wasn't... erm..." Sings with Winds stutters as she looks anywhere in the room other than your face while small whirlpools form in the liquid that make up her body. 
      
      "Well, go on, sister. Tell the director." Walks with Winds teases from her spot on the couch as she glances up from her terminal as she experiences a few small involuntary contractions in her membrane. 
      
      "Erm... it must be an error in translation. Or perhaps the director misheard me." Sings with Winds stammers. "We have work to do! We should definitely save this conversation for another time. Instead of now. Now is too important. Was there something you needed, director?" she changes the topic as she forces herself to appear normal once again. 
      *set Sings %+ 10
      *set NisaiSpeak 1
      *goto SistersConvo

Okay. Fixed one error.

The > or < goes before the = not the other way around. One issue solved.

I fixed it (I think).

  *if ((((LangNisai = 1) and (Nisai <= 3)) and ((Sexuality != 4) and (Spoken = 0))))
    *hide_reuse #"And here I was hoping you'd have a mutual attraction to me, Walks with Winds." I chuckle as I reply fluently in their native language. 
      "I... no!" Walks with Winds replies as she forces herself back to looking at the terminal as her membrane trembles. 
      
      "Aw, it's my sister's turn to be flustered!" Sings with Winds teases from the chair as her membrane contracts involuntarily. 
      
      "I am not! I'm just cold! I'm just shivering!" Walks with Winds protests as she rapidly snatches a blanket and puts it over herself. 
      
      "Our species doesn't shiver, spawn-mate, and I'm pretty sure the director knows it." Sings with Winds teases her again. "We should let her breathe though, as the saying is in your language. Take it slow with her, director. She's more fragile than she lets on." she adds as the contracts of her membrane die down. 
      
      An indignant huff leaves Walks with Winds as she turns her attention back to her terminal, though you see her membrane still 'shivering'. 
      *set Walks +% 5
      *set NisaiSpeak 1
      *goto SistersConvo

It’s at least not flagging it as an error anymore.

I was able to fix it by randomly throwing ( and ) on until it worked but I don’t understand why this code works.

Would someone be okay with explaining it to me? I have other, related errors to fix.

I have managed to break my code again.

I have now resorted to purity seals, sacred oils, and chanting.

I thiiiink it should be

*fake_choice
 *if ((((LangNisai = 1) and (Nisai <= 3)) and (Sexuality != 4)) and (Spoken = 0)) *hide_reuse #Option
  Stuff

All in one line?

I had to add another variable which is what broke it again.

*fake_choice
  *if (((((LangNisai = 1) and ((Nisai <= 3)))) and (((Sexuality != 4)))) and (((Spoken = 0)))) and (Flirt = 0))))
    *hide_reuse #"THE MOTHER OF ALL WARS HAS BEGUN!" 
      TEXT OF DOOM
      *set Sings %+ 10
      *set NisaiSpeak 1
      *goto SistersConvo

I know it has to do with the parenthesis but I can’t tell what it is. I was able to fix it earlier by adding them and just checking again but that’s a bit random and not… good for speedy coding.

It should be.

Basically with the variable it’s

( equal to the number of variables, and then in pairs.
like
*if ((a =1) and (b =1))
or
*if (((a =1) and (b =1)) and (c =1))

try changing the if to this thus

  *if (((((LangNisai = 1) and ((Nisai <= 3)) and (Sexuality != 4)) and (Spoken = 0)) and (Flirt = 0))

Trying now.

I’ve got a friend trying the game (we experienced an unrelated issue, which then eventually led to discovering this one).

Edit:

New error with your code this time.

c1 line 1172: Invalid expression at char 42, expected CLOSE_PARENTHESIS, was: NAMED_OPERATOR [and]

Character 42 is right before the 3 for me

ah, sorry, my mistake

  *if (((((LangNisai = 1) and (Nisai <= 3)) and (Sexuality != 4)) and (Spoken = 0)) and (Flirt = 0))

the (( at Nisai is the culprit here

edit:
Also, to clarify, do you want all these variable to apply in order for the choice to show, or is it different pairs? Like
((LangNisai = 1) and (Nisai <= 3)) have to apply at the same time, OR (((Sexuality != 4) and (Spoken = 0)) and (Flirt = 0)) for the option to show

I need all the variables to apply. Order of them doesn’t particularly matter.

Flirt is a temp variable just so people can’t be weird and flirt with both sisters (there is an option for that but it ends with the MC being smacked).

Nisai is the character’s opinion on their species (anything above 4 would make them ‘racist’ if that terms applies to a species. Speciesist?)

LangNisai is a language spoken. The character either speaks it or doesn’t.

And Sexuality is so that people who don’t want romance won’t see the option to pursue it.

Would the AND operator between (Sexuality != 4)) and (Spoken = 0)) not make it an and statement? It would make it an or operator?

Gotcha. Then it’s the long one with all the ands.

Godspeed :3

Thank you.

Can you explain how it’s working so I can replicate it in the future?

as here:

( equal to the number of variables, and then in pairs.
like
*if ((a =1) and (b =1))
or
*if (((a =1) and (b =1)) and (c =1))
or
*if ((((a =1) and (b =1)) and (c =1)) and (d =1))

So every variable that is meant to apply for an if to apply means one ( at the start.

If you want several sets to apply (let’s say an option would show if mc is either tall and and bald OR has the job knight (even if they’re neither tall or bald, or just one of the two)
then it should be IIRC

*if ((seize =1) and (hair =1)) or (job =1)

Though someone please correct me on this one as I am not 100%

Okay. So if I needed to do 5 variables it’d be…

*if (((((var1 = blah) and (var2 = blah)) and (var3 = blah)) and (var4 = blah)) and (var5 = blah))

Like this?

Looks about right, yes. Good luck :slight_smile:

Thanks so much for your help!

As long as they’re all linked by “and”.

For a mix of ands and ors, you might need to be able to put together something like:

((a and b) or (c and d)) or (e and (f and g))

for which you need to understand the principle of only give ChoiceScript two things at a time (where anything you group together inside a set of brackets has been turned into “one thing”).

In this example, you want an option or bit of text to show up in any of these three situations:
a and b
c and d
e and f and g

Throwing brackets around (a and b) and (c and d) turns each of them into “one thing” for CS to understand. But (e and f and g) would have three things inside the bracket. That’s too many. We need to first make (f and g) into one thing, then add e, and group that into one thing by adding another set of brackets around it all:

(e and (f and g))

That would leave us with

(a and b) or (c and d) or (e and (f and g))

which is three things, so we have to group two of them using brackets:

((a and b) or (c and d)) or (e and (f and g))

or

(a and b) or ((c and d) or (e and (f and g)))

will both work equally well. Some people like to throw the whole thing in one final bracket set

(((a and b) or (c and d)) or (e and (f and g)))

but that’s not necessary; once you’ve got it down to “two things” you don’t need to make it all “one thing.”

What wouldn’t work would be the shortcut heuristic of “well, I’ve got seven variables, so throw seven open brackets up front and add one after each new variable”:

(((((((a and b) or c) and d) or e) and f) and g)

In this case, that approach would give you:

“For this to happen, you need to have f and g, plus either e or a mess of other stuff – d plus either c or (a and b).”

which almost certainly isn’t what you’d have intended. :slight_smile:

[Edit: as MeltingPenguins pointed out below, this would also fail because I have too many open parens at the start; the heuristic applies to checking numeric or string variables, not the simple Boolean checks I’m using in this example.]

For expressions using all "and"s or all "or"s, the heuristic of “start off with as many open brackets as you have variables, then add a closed bracket after each variable” works fine.

Did dan update choicescript to the point that distribution of parenthesis would work or would quicktest protest that it is missing them?

Pretty sure what I’m describing would always have worked. And the same holds for the stack-em-up-front heuristic. Personally, I get confused by something like

(((((((a and b) and c) and d) and e) and f) and g)

because I can’t tell at a glance how many parens are in that opening stack. I’ve always preferred e.g.

((a and b) and (c and d)) and (e and (f and g))

because I can visually parse the logic. That’s always passed QT. But it’s also easy to make an error that would cause QT to choke, like

((a and b) and (c and d)) and (e and (f and g)

Edit: like the error I just realized I made last post. :slight_smile: Fixed now.