# "OR" Using the expression editor?

3absh
Member, PRO Posts:

**597**

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?

## Comments

1,893You 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?

KevinCross.co.uk | Basic Game Mechanic Templates inc. Candy Crush / Bejewelled

Games On Arcade: MineScroller | Reflexio | Doodle Kicks

597(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.

GSLearn.com| Templates | Free Demos | Udemy Course12,822If

numeric expression:x-round(x/4)= 1. . . then x must be 1 or 2.

12,822Another way:

If

numeric expression:ceil(x/2)= 1. . . then x must be 1 or 2.

4,994Using 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.

Contact me for custom work - Expert GS developer with 11 years of GS experience - Skype: armelline.support

2,239thats a lot of solutions

My Apps

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

https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de

12,822There 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.

12,822Here's another (somebody stop me !! )

If numeric expression:abs(((x-1)*2)-1)= 1. . . then x must be 1 or 2.

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

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

4,994@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

Contact me for custom work - Expert GS developer with 11 years of GS experience - Skype: armelline.support

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

round(sqrt(self.X)) = 1

Contact me for custom work - Expert GS developer with 11 years of GS experience - Skype: armelline.support

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

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

4,994@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

597Wow, I'm overwhelmed.

Thanks guys!!

597OMG I just noticed that what I actually needed was

0 OR 1

not

1 OR 2

Ultimate FAIL on my behalf.

4,994That 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.

12,822Then 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

12,822if

abs((X*2)-1)=1Only 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.

4,994oop, I mean < 2. No idea why I said > 1 I must have transposed his question to NOT 0 or 1...