Why pick by comparison doesn't compare strings?

Discussion and feedback on Construct 2

Post » Thu Feb 27, 2014 10:34 am

Hello there,
@Ashley

Just noticed, that it's not possible to compare strings in the "Pick by comparison". Why not? It would be so handy to write something like this:

Pick Objects
Object.Name
=! Not equal
"Red" | "Green" | Blue
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Thu Feb 27, 2014 10:46 am

And what about picking like this ?
You do not have the required permissions to view the files attached to this post.
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Thu Feb 27, 2014 10:59 am

This will of course work, but if you have more complex picking conditions, involving another comparisons, this "or-blocks" start to get very messy and under some circumstances doesn't work.

And you can save lots of space, if it would be possible to pick by comparing strings expressions.
Last edited by xoros on Thu Feb 27, 2014 11:03 am, edited 1 time in total.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Thu Feb 27, 2014 11:01 am

Ho, sorry, I misunderstood you. Yes, having a pickByComparison working with strings would be nice, and my solution was just a work-around to do with this problem. You are right, it would help and be more user-friendly.
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Thu Feb 27, 2014 12:10 pm

Good point, fixed for the next build so you can also use strings. Note however your given example still won't work. | is a logical operator that returns 0 or 1, so you'll be comparing the object name (string) to 0 or 1 (number) which will never be true. You could instead do that (and this works already) using 'Pick by evaluate' with an expression like:

(Object.Name = "Red") | (Object.Name = "Green") | (Object.Name = "Blue")
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Thu Feb 27, 2014 12:14 pm

Oh, that's nice.

But, in the pickByEvaluate it's not possible to use "not equal" !=
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Thu Feb 27, 2014 12:45 pm

See the manual entry on expressions, Construct 2's notation is: <>
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Thu Feb 27, 2014 1:06 pm

Ah, thanks. Now I leveled up my "picking" knowledge!

That's powerful: PickByEvaluate: (Object.Name<>"Red") & (Object.Name<>"Blue") & (Object.Name<>"Green")

The operator <> is listed in the manual, but it's not described as "not equal". And this notation is not very obvious.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests