Making text visible if multiple conditions are true

Alright, so I was trying to code a portion of my game, but no matter what I do, this part won’t work:

		*temp attempt1PLEASEDONT 0
		*temp attempt2Pls 0
		*temp pleasestop3 0
		*label choosewiselysc1
		*choice
			#You need to get out of here, and quick. Sera- (don't think about sera) You're leaving her. You'll never find her in this blizzard. Mum will understand. Anyone would.

				*if ((attempt1PLEASEDONT = 0) and (attempt2Pls = 0) and (pleasestop3 = 0))
					I'm sorry, ${Name}, but I can't let you do that.
					*set attempt1PLEASEDONT '1'
					*goto choosewiselysc1
			
				*if ((attempt1PLEASEDONT = 1) and (attempt2Pls = 0) and (pleasestop3 = 0))
					Stop this. You don't understand- he will kill us.
					*set attempt2Pls '1'
					*goto choosewiselysc1
				
				*if ((attempt1PLEASEDONT = 1) and (attempt2Pls = 1) and (pleasestop3 = 0))
					[b] STOP. [/b]
					*set pleasestop3 '1'
					*goto choosewiselysc1
				
				*if ((attempt1PLEASEDONT = 1) and (attempt2Pls = 1) and (pleasestop3 = 1))
					I can't stop you, can't I? If only I had- but it's too late now.
					*achieve tryveryveryhardtodie
					*page_break

…and so on. I’ve tried changing all the '1’s and '0’s to true and false, checked the Choicescript wiki page about the If command, but what they suggest brings up the same error that I get, which is:

Help? Please? this thing is driving me insane it’s 3:32am help

It’s the parentheses: You always have to use them in pairs. I tend to use one more set that I really need, I think, because I like to have each variable enclosed for clarity.

So here you essentially have variables A, B, and C , so:
*if (A = 0) and (B = 0) and (C = 0).

You have to make sure they’re always in units of two. So you can add parenthesis accordingly:
*if ((A = 0) and (B = 0)) and ((C = 0)).
[C is its own pair here, since you have an odd number of variables]

And then parenthesis round the lot:
*if (((A = 0) and (B = 0)) and ((C = 0))).

So for your example, try this? And sort all the lines the same way.

	*if (((attempt1PLEASEDONT = 0) and (attempt2Pls = 0)) and ((pleasestop3 = 0)))
5 Likes

Thank you. So much. I cannot express how grateful I am in words, but am trying very hard to nonetheless. :grin::grinning:

Finally!!! It’s working!!!

2 Likes

My preferred method is to just start with one comparison, then keep tacking on parenthesis and conditions, like so:

*if ((((a = 0) and (b = 0)) and (c = 0)) and (d = 0)) and (e = 0)

… And so on… But that’s just me!

1 Like

Worth noting that if you want to mix and and or conditions, things get a little more complicated. The tacking-on method (which I generally use as well for if I’m only using ands or ors) can lead you astray then!

I tried to give an example of writing a mixed and/or set of conditions here.

4 Likes

Good point, Havenstone. I hadn’t thought of that myself, but then, I haven’t had the opportunity in ChoiceScript to use more then two chained conditions. Now that you’ve brought it up, I’m not entirely certain how exactly I’d deal with such a situation. I guess we’ll see when I get there!

Not sure if it’s mentioned in your example, but a good method for keeping things simpler with chained conditions is to use a *temp variable and take things one comparison at a time, in the correct order of course. This is easier to bug fix then trying to sort out all those parenthesis, especially in ChoiceScript where everything has to be paired up.

1 Like

It does work so there’s no real harm in doing it that way, but strictly speaking (and to save confusing anyone still trying to grasp the logic here!) the basic “rules” for this method are actually much simpler than it may at first seem:

A. For a single condition on a line of its own no parentheses are actually required, e.g.

*if var1 = 5

B. If the condition accompanies something else on the same line, it must be wrapped in parentheses, e.g.

*if (var1 = 5) #This is a valid option

or

*if (var1 = 5) and (var2 = 5)

C. However, only in the event that the line contains something else do they need to be wrapped in additional parentheses and be considered “a pair”, e.g.

*if ((var1 = 5) and (var2 = 5)) #This is a valid option

or

*if ((var1 = 5) and (var2 = 5)) and (var3 = 5)

Note that the third condition is not “a pair” and does not require extra parentheses, nor does the whole thing need wrapping in yet another set - unless there’s once again something else on the same line, like an option:

*if (((var1 = 5) and (var2 = 5)) and (var3 = 5)) #This is a valid option

Although by this stage you may as well keep things simple and just indent the #option itself on the following line:

*if ((var1 = 5) and (var2 = 5)) and (var3 = 5)
    #This is a valid option

D. Additional “pairs” (and pairs of pairs) can be handled as follows:

*if ((a = 1) and (b = 1)) or ((c = 1) and (d = 1)) 
*if (((a = 1) and (b = 1)) or ((c = 1) and (d = 1))) or (e = 1) 
*if (((a = 1) and (b = 1)) or ((c = 1) and (d = 1))) or ((e = 1) and (f = 1)) 
*if (((a = 1) and (b = 1)) or ((c = 1) and (d = 1))) or ((e = 1) and (f = 1)) or (g = 1) 
*if (((a = 1) and (b = 1)) or ((c = 1) and (d = 1))) or (((e = 1) and (f = 1)) or ((g = 1) and (h = 1))) 

Whether to use and or or at each join will of course depend on precisely what you’re trying to determine with the *if, but as you can (hopefully) see it really is just a case of wrapping each “pair” and each “pair of pairs” in extra parentheses, whereas odd conditions (a 3rd, 5th, 7th, 9th…) can just be tacked on the end with no problem.

5 Likes

I now know more about making text visible when multiple conditions are needed and the strange beings that are parenthesises (brackets?) than I ever knew there was to know about :grin:

2 Likes

It actually depends where you live… but generally (these are parentheses) and [these are brackets]. However, if you normally call (these brackets) then [these are called square brackets]! Fascinating, huh? :smiley:

2 Likes

Don’t forget your “curly brackets”! { and }. Pretty sure these also have a real name, but I’m too lazy to even google it to find out. To me, “brackets” is more of a catch all term for all three kinds.

2 Likes

Now you’ve summoned the pedant in me! :wink:

(parentheses)
[brackets]
{braces} or if you prefer {curly braces}

4 Likes