It looks like you're new here. If you want to get involved, click one of these buttons!

abuabed84
Posts: **490**Member, PRO

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?

0

## Comments

1,893MemberYou 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

511Member, BASIC(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,822MemberIf

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

12,822MemberAnother way:

If

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

4,692Member, PROUsing 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 9 years of GS experience - Skype: armelline.support

2,239Memberthats 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,822MemberThere 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,822MemberHere's another (somebody stop me !! )

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

11,613Member, Sous Chef, PRO, Senior Sous-ChefWhen numeric expression textFind("#1#2","#"..self.x,1) ≠ -1

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

4,692Member, PRO@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 9 years of GS experience - Skype: armelline.support

4,692Member, PROVery similar to one @Socks already did, but different enough!

round(sqrt(self.X)) = 1

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

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

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

4,692Member, PRO@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

490Member, PROWow, I'm overwhelmed.

Thanks guys!!

490Member, PROOMG I just noticed that what I actually needed was

0 OR 1

not

1 OR 2

Ultimate FAIL on my behalf.

4,692Member, PROThat 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,822MemberThen 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,822Memberif

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,692Member, PROoop, I mean < 2. No idea why I said > 1 I must have transposed his question to NOT 0 or 1...