The or condition

Discussion and feedback on Construct 2

Post » Mon Apr 16, 2012 1:30 am

@arima,

i think i am really losing it...lol. i thought i read an example of a multiple 'or' condition statement, and a multiple 'or' trigger statement in this tutorial...
http://www.scirra.com/tutorials/292/guide-to-construct-2s-advanced-event-features
i may need medical help to sort this all out.


B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

Post » Mon Apr 16, 2012 1:37 am

Notice there is only one condition between each or in those examples. You can't have:

Sprite.x=1
Sprite.y=2
or
sprite is visible

If you try it, it will result in:


Sprite.x=1
or
Sprite.y=2
or
sprite is visible
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Mon Apr 16, 2012 1:48 am

[QUOTE=Arima]
For example:

If right arrow is down
or
If D is down
- set sprite x to sprite.x+1

[/QUOTE]

I've tried that in Construct Classic and it works as it should. The sprite is moved 1px forward no matter if I press one or both keys at once. And in C2, as you said, it moves double speed, so it's definitely bug.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Mon Apr 16, 2012 2:24 am

Well you're right, OR is kind of broken in my first implementation in r86. I was a bit naive with the implementation - if you make an event:

A or B or C: do actions

it pretty much gets run as three separate events:

If A: do actions
If B: do actions
If C: do actions

I think the examples in this thread have proven that's totally broken, since if more than one condition is true and you toggle something, it gets toggled straight back. Whoops! Or movements speed up, counters get too much added, etc.

Luckily I've already changed it for the next build. There might still be bugs in the next release, but it's changed to only runs the actions once even if multiple conditions were true. So

A or B or C: do actions

will run once if at least one condition was true. It also properly handles picking, so:

+ Sprite X < 320
- or -
+ Sprite Y < 240
-> do something with Sprite

will now correctly run the actions once with the picked objects being those instances which match either condition.

r86 kind of had a lot of bugs with the new event features! 'Else' and 'While' both have some weird issues as well. I think I've fixed everything for the next build though. Thanks for the feedback though. It's lucky we've got the beta and stable releases sorted out, this is kind of what we expected - smoothing things out over a few beta releases then getting a stable update out which hopefully works as expected.Ashley2012-04-16 02:24:36
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Apr 16, 2012 2:37 am

Fantastic! :) Thanks, Ashley! Any word on allowing multiple conditions between ors as well?
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Mon Apr 16, 2012 4:35 am

That's awesome Ashley, thanks for looking into it
I also like Arima idea here about combining multiple condition.

right now just to achieve something as simple as:

[code]
(Condition 1 OR Condition 2) AND (Condition 3 OR Condition 4)
or:
(Condition 1 AND Condition 2) OR (Condition 3 AND Condition 4)
[/code]

it will need multiple event, making it harder to read.
If we can just combine that condition in 1 block it would be suh-weeett...Potato2012-04-16 05:02:51
B
34
S
13
G
8
Posts: 134
Reputation: 8,118

Post » Mon Apr 16, 2012 6:10 am

thank you gents,

i was afraid i was losing it...lol. i think i'll hold off on answering questions and just stick to reading the forum. i think i was more of a hinderance to arima [or] anyone [else] reading it, than a help...lol.
B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

Post » Mon Apr 16, 2012 6:38 am

Hey, no worries @harrio, don't let it discourage you from being involved on the forum!
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Mon Apr 16, 2012 2:59 pm

@Arima - I deliberately went with the "Or block" design because it is very simple. Allowing multiple conditions between ORs becomes significantly more complicated, both in the editor's rules for valid events, the usability and in the runtime engine. So I opted for something simple which is easy to use and robust.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Apr 16, 2012 3:58 pm

Thanks Ashley,

this will make my code half or less size than the actual, because the logic behind OR, ELSE, etc are made to compact the codes. Nothing wrong with the old system, but these conditions make easy and faster Our job.
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: NetOne and 1 guest