# "OR" Using the expression editor?

I want to write this:
When attribute X = 1, or 2
but I need to write it using the expression editor not the "When ANY conditions are valid"
which of the expression editor function does this?

• edited August 2016

You could use any.

When Any
If x = 1
If x = 2

Or like this

When All
If x >= 1 and x <= 2

Why does it need to be written in the expression editor/text box?

• (Game.Attribute==1)and(DOACTIONFOR1)or(Game.Attribute==2)and(DOACTIONFOR2)or(DOACTIONIFNONEAREMET)

I use this every now and then. Not sure if its most practical solution though.

• edited August 2016

If numeric expression: x-round(x/4) = 1

. . . then x must be 1 or 2.

• edited August 2016

Another way:

If numeric expression: ceil(x/2) = 1

. . . then x must be 1 or 2.

• Using Numeric Expression:

(game.X==1)or(game.X==2) = 1

The = 1 is the built in = and the 1 is in the right hand box. It does exactly the same as @KevinCross suggested, though. There's no advantage to this over his way.

• thats a lot of solutions

My Apps https://itunes.apple.com/de/artist/david-zobrist/id733552276

• edited August 2016

@BigDave said:
thats a lot of solutions

There are probably an infinite amount of solutions to this (I think).

Here's another If numeric expression: abs(floor(x*1.5)-2) = 1

. . . then x must be 1 or 2.

• edited August 2016

Here's another (somebody stop me !! )

If numeric expression: abs(((x-1)*2)-1) = 1

. . . then x must be 1 or 2.

• edited August 2016

When numeric expression textFind("#1#2","#"..self.x,1) ≠ -1

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• edited August 2016

@tatiang Love it! Another (not as good) textFind option:

max(textFind(self.X,"1",1),textFind(self.X,"2",2)) = 1

(This breaks pretty easily though, if the conditions are too wide. Like, say, 11. That can be fixed by throwing two min(x) in there though.)

max(textFind(min(self.X,3),"1",1),textFind(min(self.X,3),"2",2)) = 1

• Very similar to one @Socks already did, but different enough!

round(sqrt(self.X)) = 1

• @Armelline said:
Very similar to one @Socks already did, but different enough!

round(sqrt(self.X)) = 1

I see your square root and raise you a sine function:

ceil(sin(min(( self.X *90)-1,181))) = 1

• @Socks I don't think anyone is going to beat a sin() one. One more anyway, though! We've not had any where the result has to be 2 yet.

ceil((self.X*5)/10+1) = 2

• Wow, I'm overwhelmed.
Thanks guys!!

• OMG I just noticed that what I actually needed was
0 OR 1
not
1 OR 2
Ultimate FAIL on my behalf.

• That makes it much easier. If X can only be positive numbers, just say x > 1.

If X can be negative, it gets a little more complicated but it still very much doable.

• edited August 2016

@Armelline said:
That makes it much easier. If X can only be positive numbers, just say x > 1.

Then 3 (and 7,928 and 4.32 . . etc) would pass the condition ? But 0 and 1 would fail ? Maybe I misunderstand what you are saying, but either way this is highly controversial maths • edited August 2016

if abs((X*2)-1) =1

Only 0 and 1 will pass this condition.

Or (as Armelline says) if you are only using positive integers then you can simply check for x < 2.

• @Socks said:

@Armelline said:
That makes it much easier. If X can only be positive numbers, just say x > 1.

Then 3 (and 7,928 and 4.32 . . etc) would pass the condition ? But 0 and 1 would fail ? Maybe I misunderstand what you are saying, but either way this is highly controversial maths oop, I mean < 2. No idea why I said > 1 I must have transposed his question to NOT 0 or 1...