The OR operator is not working!

Bugs will be moved here once resolved.

Post » Wed Dec 28, 2011 9:51 pm



The | OR operator isn't working, it works fine when I just compare it to "block1" but when I try to compare to "block1" | "block3" it doesn't work!
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Wed Dec 28, 2011 10:07 pm

I can't continue my game until this is fixed

The alternate way affects performance badly.
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Wed Dec 28, 2011 10:08 pm

The OR operator doesn't do what you've assumed it to. It's a logical OR which returns either true or false. An empty string counts as false and other strings count as true. So "block1" | "block3" | "block13" | "block14" results in 'true', and you then do the comparison 'Block.AnimationName = true', which it probably isn't, so the event never runs.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Wed Dec 28, 2011 10:11 pm

[QUOTE=Ashley] The OR operator doesn't do what you've assumed it to. It's a logical OR which returns either true or false. An empty string counts as false and other strings count as true. So "block1" | "block3" | "block13" | "block14" results in 'true', and you then do the comparison 'Block.AnimationName = true', which it probably isn't, so the event never runs.[/QUOTE]

Is there a way around this? Without having to use it with 4 events, There are reasons why and I don't want to go into too much detail until I release the game, I'm sadface :(
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Wed Dec 28, 2011 11:33 pm

@dcrew: You should take a look at the custom OR plugin.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Thu Dec 29, 2011 1:39 am

[QUOTE=Kyatric] @dcrew: You should take a look at the custom OR plugin.[/QUOTE]

While this plugin is great, it only seems to handle 2 different conditions, I want block1 OR block3 OR block 14 OR block 15, This won't exactly work for me.
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Thu Dec 29, 2011 3:29 am

It's a logical operator. You can't compare against a collection of logical or'd strings. I don't use C2, so I can't say if this is doable with the event system, but the correct way to get what you want would be:

Block.AnimationName = "block1" | Block.AnimationName = "block3" | Block.AnimationName = "block13" | Block.AnimationName = "block14"

This will result to true, if Block.AnimationName equals one of the four strings.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu Dec 29, 2011 11:36 am

[QUOTE=tulamide] It's a logical operator. You can't compare against a collection of logical or'd strings. I don't use C2, so I can't say if this is doable with the event system, but the correct way to get what you want would be:

Block.AnimationName = "block1" | Block.AnimationName = "block3" | Block.AnimationName = "block13" | Block.AnimationName = "block14"

This will result to true, if Block.AnimationName equals one of the four strings.[/QUOTE]

I tried that one and it says:

B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Thu Dec 29, 2011 1:04 pm

Of course it does say so. You would have to "or" the comparisons itself. So that you have 4 comparisons in that event that are or'd. With CC you would do

Block.AnimationName = "block1"
OR
Block.AnimationName = "block3"
OR
Block.AnimationName = "block13"
OR
Block.AnimationName = "block14"

and every line is one condition (4x Comparison, 3x OR). I guess then it isn't possible to "or" conditions in C2? But in the manual it is described as if possible:
http://www.scirra.com/manual/78/expressions/page-1
Maybe there is "evaluate" as a system condition?

EDIT: In general, remember that any logical operator just compares to boolean values (TRUE or FALSE) and nothing else. Those values may be replaced by expressions/conditions that result to either TRUE or FALSE (like "if a is greater b"), but it needs to be something that results in a boolean value.tulamide2011-12-29 13:11:34
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu Dec 29, 2011 1:34 pm

[QUOTE=tulamide] Of course it does say so. You would have to "or" the comparisons itself. So that you have 4 comparisons in that event that are or'd. With CC you would do

Block.AnimationName = "block1"
OR
Block.AnimationName = "block3"
OR
Block.AnimationName = "block13"
OR
Block.AnimationName = "block14"

and every line is one condition (4x Comparison, 3x OR). I guess then it isn't possible to "or" conditions in C2? But in the manual it is described as if possible:
http://www.scirra.com/manual/78/expressions/page-1
Maybe there is "evaluate" as a system condition?

EDIT: In general, remember that any logical operator just compares to boolean values (TRUE or FALSE) and nothing else. Those values may be replaced by expressions/conditions that result to either TRUE or FALSE (like "if a is greater b"), but it needs to be something that results in a boolean value.[/QUOTE]

There's no OR or EVALUATE condition as I've just checked, But I guess I'll just wait for Ashley and Tom to release 74 with the fixes OR thing for this: Click Here!
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests