Trying to use 'or' but it's not working


#1

I don’t know if I’m being dumb and not using it right, or what.

I have a choice I only want to show up if either variables are true. So-

*label problems
*choice
  *if not(var1) or not(var2) #Choice
       *set var 1 true
       *set var 2 true
        *goto problems

The idea is that when you choose that option, it sets a var1 true (and just to make it easy, var 2, too, though in reality it doesn’t get set true until a choice further in). But, every time I loop back, it doesn’t work. The choice still shows up. Though, if I trigger the second variable, it disappears (like an and). If I delete the second variable in the choice it works though.


#2

I think it should be

*choice
  *if ((var1 = false) or (var2 = false)) #option
    stuff
    *goto place

I’ve had trouble using *if not (var) in multi-variable *if statements so I do that, but most importantly you need the double parentheses. Also make sure your *goto is indented correctly. It looks like you have an extra space above


#3

In addition to what @sviyagin suggested, you should also do:

      *set var1 true
      *set var2 true

instead of

       *set var 1 true
       *set var 2 true

(Since, the space 'n all.)


#4

@sviyagin I gave it a go but doesn’t seem to work either.

@UNOwen That’s my fault, that’s not how it’s actually written in my game (didn’t want to write it all out cause it’s scenes that are completely written out and didn’t want to make it look more convoluted than it needed to be :p)


#5

Can you tell us the error you get when you run quicktest and/or randomtest?

Edit: I also just noticed that this is a loop. I.e. when your code runs this and goes to *label problems, it re-runs the same code


#6

I’m not getting any errors.

Technically how I have it is there’s a couple of choices, but as you go through them and trigger certain variables, they disappear. So when you pick the first option you can trigger it’s variables one of two ways (so basically you can back out and choose it again). After you go through the scenes it’s supposed to loop back. If I go through and trigger the second variable, it disappears like it should, but not with the first one. If I take away the second variable (so it’s just *if not(var1)) it triggers as well.


#7

Why not copy-paste the section(s) in question and then replace the actual text with something like ‘[text]’? Maybe you misspelled one of the variables you’re trying to set?

Edit: In addition, are you certain you tried:

*if ((not(var1)) or (not(var2))) #Choice

#8

It’s hard to visualize what you mean by “it doesn’t get set true until a choice further in.” Could you post the entire section of code?


#9
*label top
*choice
	*if (not(chance) or not(rchance))
		#Look for Chance
			[text]
			*choice
				#A good friend
					[text]
					*choice
						#Go with him
							[text]
							*if not(unimportant variable)
								[text]
								*set chance true
								*choice
									#Go back 
										*goto top
									#It's time to go home
										[text]
										*return
							*else
								*set chance true
								*goto bottom
						#Go look for someone else.
							[text]
							*set rchance true
							*goto top
				#Go look for someone else.
					*goto top

*label bottom
[text]
*goto top

This is the entire segment of code (sans paragraphs). I wondered if it was the placement of the variable to set it true.

Just tried doing the parenthesis that way and still a no go.


#10

Hmm.

Are you trying to make it so that if the player sets off either chance or rchance the option hides? In which case, you’re using the wrong expression. Use ‘and’ instead of ‘or’. The way it currently is, both flags need to be set for the choice to hide.


#11

Gaaaaaah.

I’ve been messing around for choicescript for years and apparently didn’t understand the and function.

This might explain some things.

Thank you!


#12

No problemo.

This is why posting the entire code was important – in the example you gave us in the opening post, both flags seemed to be set properly and at the same time, so there was no way to properly tell what the issue (or what you were trying to do exactly) might’ve been.


#13

code stretching thirty meters off the right side of the screen

This is why I use double space instead of tab or quadruple space!


#14

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the @moderators.