Restrict expression/actions inside events

0 favourites
  • 4 posts
From the Asset Store
Alot of High Quality Items sound effects for your game!
  • I couldn't find any information about this, sorry if my google-fu is weak.

    I was wondering if it's possible to restrict certain expression/actions to be called ONLY inside a certain event.


  • Why would you want to do that? This kind of thing contradicts the way the rest of the event system is set up, so I would discourage it anyway. Some official plugins have actions/expressions which can only be used in certain triggers, but if used outside of that they are just a no-op or return an empty value.

  • Because I personally do no like having a function returning an unexpected result.

    If a condition can be called only inside a certain trigger and it gets called outside said trigger, in a normal programming environment it should raise an exception.

    Since as far as I know there is no exception handling in Construct, it would make sense to have a parameter in the condition that forces the user to place that condition only inside the specified trigger, if not it should display (in the editor) a warning or an error, sort-of like how the Local Storage displays the [Certain events can not be moved due to restrictions on the trigger].

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The edit-time restrictions are very general purpose, e.g. preventing two triggers in one event. It's true the C2 event system has no model for exceptions - typically things resort to empty values or no-ops, which I think is reasonable given the goal of making the event system easy to use: instead of trying to figure out why exceptions are breaking everything, events tend to continue to work anyway. Some plugins use an "On error" trigger so the user can find out if something went wrong, I'd suggest using that model as well.

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