Multiple possible tiles? Logical operators?

Get help using Construct 2

Post » Mon Apr 10, 2017 10:20 pm

Is it possible to use a "|" (OR operator) to give optional returns for all these? It would really cut down on some of my events. This could also go for the "&" (AND operator).

In other words, in the highlighted part in the image below, instead of just looking for tile "13", could I do tile "13|14|15" etc? Does anyone have experience with this? This is using the TileMap object.

Image
B
27
S
6
G
6
Posts: 267
Reputation: 3,750

Post » Mon Apr 10, 2017 11:18 pm

Just did some experimentation, no go. If anyone has experience with this, please offer some advice. It would be easier than having a ton of events that all say the same thing except the tile.
B
27
S
6
G
6
Posts: 267
Reputation: 3,750

Post » Mon Apr 10, 2017 11:27 pm

You can have a single event with all the compare tile conditions with different target tiles and right click to turn it into an OR block.

Edit: Alternatively, you can use the System-General-Is between values condition with the tileat(x,y) condition.
Last edited by oosyrag on Mon Apr 10, 2017 11:30 pm, edited 1 time in total.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Post » Mon Apr 10, 2017 11:29 pm

Use loop "for" with start index = 0, end index =2. Change the value (from highlighted) into 13+loopindex
ImageImage
B
111
S
51
G
24
Posts: 786
Reputation: 23,392

Post » Tue Apr 11, 2017 12:36 am

Your best bet is probably a function. 1st and 2nd parameters are the coordinates, and the rest are tile ID that are to be checked.

Image
B
74
S
31
G
26
Posts: 994
Reputation: 20,198

Post » Tue Apr 11, 2017 10:20 am

Thank you all for the responses, guys. I'm gonna play around with various techniques. Thanks again!
B
27
S
6
G
6
Posts: 267
Reputation: 3,750

Post » Fri May 05, 2017 8:57 pm

There definitely should be a simple way to provide multiple values to check. I've needed this in the past numerous times. Current methods aren't that satisfactory for me due to the complexity it introduces to the eventsheet. :\
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Fri May 05, 2017 10:55 pm

You actually can use | as an "or" operator in an expression, which returns 0 for false and 1 for true. This can be combined with system compare two values to set your condition. ref: https://www.scirra.com/manual/78/expressions

It will reduce the number of events, but also decrease readability.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Post » Fri May 05, 2017 11:34 pm

yeah, that's an option, but still is not adequate in my opinion.
In my case, I just added the ability to specify multiple tiles via a string "0,1,2" to a custom Behavior (I created a behavior where I just add stuff that is missing from c2).. So now I can do it in a readable fashion. This should be made available by default though. I submitted the suggestion to their suggestion thing.
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Fri May 05, 2017 11:40 pm

Include a link to your suggestion! I don't think people check that regularly at the moment, so its always good to provide the link to specific suggestions in relevant threads.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, RandomlyMooN and 6 guests