OR block content executing multiple times.

0 favourites
  • 4 posts
From the Asset Store
Place blocks on a board, join them together to form even bigger blocks!
  • 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:

    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.

    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:

    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

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Triggers are not normal event. You can't OR them.

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)