"Or" expression

Get help using Construct 2

Post » Thu Jul 18, 2013 6:04 pm

Hello everyone! I'm actually doing a tileset system for my game and i need some help about something.

"Tiles" on collision with player
"Tiles" compare frame: 12 | 15 //This is the two tiles i use

Events:
Set "Tile" solid disabled

But the :
"Tiles" compare frame: 12 | 15 //This is the two tiles i use

Not working, i want a thing like 12 or 15 or xx or ...
It's working fine with just a number.
B
6
S
2
Posts: 46
Reputation: 769

Post » Thu Jul 18, 2013 6:57 pm

Can you even use that or symbol in construct? I didn't know that.
Why don't you just make two conditions and set the block as an "or" block. Right click the block with the conditions and if one condition in that event is true then it will do the actions.
If you want to do a "and" and "or" block, you have to make a sub event block for that unfortunately, but I'm certain it will work.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Thu Jul 18, 2013 11:18 pm

You can use the '|' symbol, but not everywhere. For your frame check, the standard event mechanism works. Picking allows you to evaluate an expression with symbols. Both are shown here:



ORsample
ImageImageImage
B
71
S
19
G
179
Posts: 3,478
Reputation: 102,672

Post » Thu Jul 18, 2013 11:56 pm

@blackhornet, was not aware of this, thanks
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Fri Jul 19, 2013 12:14 am

Actually I did figure out a third way, which I was wanting to be my second way, but the system is a bit convoluted.

You should be able to check an expression without the condition ? result_if_true : result_if_false, but C2 requires this extra step.
ORsample_plus
ImageImageImage
B
71
S
19
G
179
Posts: 3,478
Reputation: 102,672

Post » Fri Jul 19, 2013 12:00 pm

Note that 'or' in expressions is a logical OR, so "12 or 15" (alternative syntax "12 | 15") equals 1, because both operands are nonzero.
Scirra Founder
B
378
S
219
G
84
Posts: 23,863
Reputation: 187,909

Post » Sun Jul 21, 2013 8:20 pm

That's can be really long if we have +100sprites to add with the "or" block, i knew it was existing, but i needed to find a fastest way
B
6
S
2
Posts: 46
Reputation: 769

Post » Sun Jul 21, 2013 8:31 pm

You're doing something wrong if you need 100 OR comparisons. Maybe post what you've got so far for review.
ImageImageImage
B
71
S
19
G
179
Posts: 3,478
Reputation: 102,672


Return to How do I....?

Who is online

Users browsing this forum: blaze ritter, Fenix18, iEatwe, kiko2015, nad10221, QuantumMMX and 12 guests