OR block content executing multiple times.

Discussion and feedback on Construct 2

Post » Fri May 23, 2014 9:37 pm

Ok, I'm not sure if this is a bug or if I'm just missing something. Anyway, while I was working on my game I noticed some strange behavior, after testing a bit I realized the following:

If an OR block has 2 or more conditions that have the same result, the actions corresponding to the OR block will execute once per each condition.


I made a quick project just to test this.

The project displays the number 0.
If you press the Up Arrow the number will increase by 1.
If you press the Down Arrow the number will decrease by 1.

The text object is called "Text" and it has an instance variable called number.

This is the event sheet:

Image
So far it works fine, but if we make an OR block and add a second condition(which has the same result), the actions will execute twice.

Image
Now, when pressing Up the number will increase by 2 instead of one. And if we added a third same condition it would increase by 3.

The obvious "fix" would be to not use the same condition more than once, but sometimes you have to use different conditions which have the same result. Example:
Image
If the value stored in the dictionary's key is the same value for the Up Arrow then the number will increase by two just like it would with the code in the second image.


In my actual game, there is a menu for the user to customize the controls, by default the Arrow keys control movement (you move up with the Up Arrow key, etc). The relation of keys is stored in a data dictionary.

The problem arises during menu navigation. I want the user to move from one option to the other using both: The arrow keys and whatever keys they defined. And, as I mentioned earlier, the default keys are the Arrow keys, this lead me to a situation exactly the same as in the third image (an event which asks if the Up key or a keycode corresponding to the Up key has been pressed).

I'm sure there can be a few workarounds, but the problem is the code behaving in an unexpected and unintuitive manner. Even if I have the same condition more than once in an OR, I would expect the corresponding actions to execute just once.


So... is this somehow normal and I should just use a workaround or should I post this in the bug section :?:
B
28
S
3
G
1
Posts: 29
Reputation: 1,698

Post » Fri May 23, 2014 9:59 pm

If it really is the problem you are describing, then it is not the intended behavior of an OR block (since OR block should act like an OR operator, not triggerring multiple times if multiple conditions are true), and so a bug report should be done I think.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Fri May 23, 2014 10:23 pm

Triggers are not normal event. You can't OR them.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Fri May 23, 2014 11:17 pm

blackhornet wrote:Triggers are not normal event. You can't OR them.


Then C2 should prevent us to do it, either way, seems more like a bug rather that intended
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123


Return to Construct 2 General

Who is online

Users browsing this forum: lukewasthefish and 8 guests