Preventing cyclic triggering

0 favourites
  • 3 posts
From the Asset Store
Antisuspend Plugin for Construct 3 prevents the runtime from getting suspended.
  • I am up to a board strategy game. The way I want its controls to be is- when I double tap a troop that is not active, it gets enabled. When I double tap an already active troop, it gets disabled.

    But it's giving me some trouble and I can't figure it out, for the manner I have handled it, at double tapping troop, it gets first activated and them deactivaed. Or viceversa. It all depends on the order of the events.

    If I place first the activate event, it triggers for a non active troop, thus it being active for the time the next deactivate event takes place. So it recognizes it as active and disables it.

    If I swap the order, it deactivates and then recognizes it being non active and activates it. So it is always a loop.

    I need it to check the first event (troop being active or inactive, doesn't matter), and be it true, trigger skipping the next event-block. Only when being false the first event-block, it would step on to the next event-block. Otherwise, doesn't take it into account.

    1drv.ms/u/s!AojCIgmN1VlPgYVKToDc8b5aVFaRkQ

    I must be missing something pretty basic. Remember vaguely having read something about it somewhere around 'if, else, run once...', 'how events work' or maybe on the loops section, but I cannot find any reference now there nor the forum.

    edit- nevermind, it was 'else' that I tried but had put it on the main triggering condition. Now in the sub-event is properly working as expected. Rookie fail...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need to use 'Else'. Event 5 was close. Check for equal -> Drop Else -> Pick.

  • I even found a more elegant solution than sub-events with Else. Given there are just two options, a ternary operator does the job with just one line of code:

    - On double tap gesture on Troop >

    > Call function ( Troop.UID = ActiveTroop ? "DropTroop" : "PickTroop" ) (Troop.UID)

    I eventually managed to find the post from the forum I read it from and then ended up here:

    construct.net/en/make-games/manuals/construct-3/project-primitives/events/expressions

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