Robust way of using "or" block

Get help using Construct 2

Post » Thu Dec 31, 2015 5:37 pm

At this moment when using an "or" block in the event sheet, it is possible to specify only 1 condition before it is seperated by the "or" statement.
So If I have 3 IF's in an event, and add an "or" all three are seperated automatically moving each IF into a different "group" followed by or, which can be really annoying.

Its not possible to have little groups of IF's and select manually which IF's are divided by the "or" statements. This produces problems when I want to use an ELSE IF statement when using the "or blocks", and need to end with an ELSE statement. The problem is when I have 2 more events/conditions with 3 or more IF statements, then its not possible to introduce one Else IF, but two need to be ELSE statements which renders one of them not functional.

So to present what I mean more visually:

What I would like:

IF x=z
and
IF x=b
or
IF x=c


What I am getting automatically:

IF x=z
or
IF x=b
or
IF x=c


Now the above example is just for example sakes and doesnt reflect the exact IF statemets I have, which cannot be solved any other simpler way than using the or block with robust function implemented. I end up having to work my way in circles to try and solve this issue through additional variables and the likes.

If its not possible to pick manually which IF statements should be divided by "or" statements, I strongly believe it should be as this feature would help tons when implemented.
Brick by brick, stone by stone.
B
56
S
25
G
18
Posts: 273
Reputation: 13,363

Post » Thu Dec 31, 2015 5:57 pm

I guess using a local variable for this is the easiest, like in this thread:

viewtopic.php?t=64032&start=0#286613
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 5:59 pm

@LittleStain

Well as I have so many variables already the best solution would be to use and and or block like I stated above. It would be ten times faster than adding another variable and looking for it, and yet making the variable list even longer, which would make searching for other variables down the line even longer because of the one additional variable.

I know there are other ways around, like I had written but adding variables quickly stops being a good alternative as the lists get longer.
Brick by brick, stone by stone.
B
56
S
25
G
18
Posts: 273
Reputation: 13,363

Post » Thu Dec 31, 2015 6:06 pm

Solomon wrote:@LittleStain

Well as I have so many variables already the best solution would be to use and and or block like I stated above. It would be ten times faster than adding another variable and looking for it, and yet making the variable list even longer, which would make searching for other variables down the line even longer because of the one additional variable.

I know there are other ways around, like I had written but adding variables quickly stops being a good alternative as the lists get longer.


I am talking about local variables, not global..
There is usually no reason to have a very long list of global variables, because most of them can be local variables or instance variables or array-values or dictionary-object values..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 6:10 pm

@LittleStain

I still have a long list of variables both global and local when I search for variables to add to the "compare to" event. Is there a way to filter only local variables so that only these would be shown when looking for variables? The fact that the icon is different for local/global does not cut it for me sadly.
Brick by brick, stone by stone.
B
56
S
25
G
18
Posts: 273
Reputation: 13,363

Post » Thu Dec 31, 2015 6:25 pm

Ok, strange..
Local variables can only be accessed in their scope, so they shouldn't show up in the dropdownbox if they aren't available..

Sounds like the way you have set up your variables might not be the best way..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 6:28 pm

@LittleStain - Local variables are indeed shown only when they are within their scope but what I am trying to tell you that all the other global variables are shown there too, besides the local variables. That does not help as the list is getting longer. This has nothing to do with how I set up my variables I dont think, only how C2 displays the lists of variables - both global and local are in the same bag when looking for local (not when looking for global), unless indeed there is something wrong with my workflow, thus I am trying to find out.

Edit: To illustrate:

What happens:


Looking for local variables - list:

Global variables x 1000
Local varibales x 10

Looking for global variables - list:

Global variables x 1000

What I would like:

Looking for local variables - list:

Local varibales x 10 -----> only - no global variables available to choose --> makes list waaaay shorter

Looking for global variables - list:

Global variables x 1000
Last edited by Solomon on Thu Dec 31, 2015 6:33 pm, edited 2 times in total.
Brick by brick, stone by stone.
B
56
S
25
G
18
Posts: 273
Reputation: 13,363

Post » Thu Dec 31, 2015 6:32 pm

Solomon wrote:@LittleStain - Local variables are indeed shown only when they are within their scope but what I am trying to tell you that all the other global variables are shown there too, besides the local variables. That does not help as the list is getting longer. This has nothing to do with how I set up my variables I dont think, only how C2 displays the lists of variables - both global and local are in the same bag when looking for local (not when looking for global), unless indeed there is something wrong with my workflow, thus I am trying to find out.


I'm just wondering why your list is so long..
Shouldn't be nescessary..
Like I said, there are other ways to keep global values, which as you see now, you cou'd benefit from..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 6:37 pm

This has been requested before. Another solution would be to use the system->"compare" or "pick by comparison" with one expression like:
Code: Select all
(x=z) & (x=b) | (x=c)
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991

Post » Thu Dec 31, 2015 6:39 pm

Solomon wrote:What I would like:

IF x=z
and
IF x=b
or
IF x=c



Well you can't simply mix "or" and "and" inside a single event, because there's actually two way to interpret this:
- "A and (B-or-C)"
- "(A-and-B) or C",

If you're looking for the first one, simply put one part into an event, and the second part into a sub-event like this :
--> If A
_____ --> If B
___________-or-
___________C

If you're looking for the second one, it's gonna be a little more tricky indeed. And local variable seems like the best way to work around that indeed:
B
7
S
3
G
3
Posts: 56
Reputation: 2,240

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, dop2000, newt, RODInteractive, Yahoo [Bot] and 27 guests