0 Favourites

Trigger once at start of layout

  • I'm not sure if this is a bug, but I have a global variable that has an event, "if variable = 0, set othervariable to 10 - trigger once while true". Every time the layout switches and the global variable stays static, it's re-initializing the trigger once condition and setting the othervariable to 10, which it should not be doing. Is it supposed to do this?

    PS. I have the trigger once event on a master sheet for all of the layouts.

  • I'm kinda confused but yes, if you have a master sheet for every layout and you have "On Start of Layout", this will run everytime you start layout, even if you change layouts, and even if it says "trigger once".

    By having "Trigger Once" on it you're basically telling the program "hey, do this thing ONCE everytime I open a new layout".

    If you want it to run once at the beggining of the game and that's it, maybe you can use "On Loading Finished".

  • andreyin - The thing is, the "if global variable = 0" does not include, or is a subcondition with "on start of layout". It's just a global event, yet it's not being treated as a global event.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • REPOST CAPX

    This is what I'm talking about. If you left click to increase the variable, when switching layout, it's triggering the variable event even though the variable isn't changing.

  • Shameless bump.

  • That's how events work.

    First of all, your link doesn't work.

    Then, events will trigger and their action will apply EVERY TIME their condition is true.

    If you check if the value of a global variable is 0, it will check it every tick. And every tick its condition is true, its action will be applied.

    In that case, use this variable only for this case (don't change its value anywhere else in the code) and simply make the first action of the event to modify the value from 0 to 1.

    This way, it will not execute again.

    Also beware if you reset global variable, then this event will trigger again.

  • That's how events work.

    First of all, your link doesn't work.

    Then, events will trigger and their action will apply EVERY TIME their condition is true.

    If you check if the value of a global variable is 0, it will check it every tick. And every tick its condition is true, its action will be applied.

    In that case, use this variable only for this case (don't change its value anywhere else in the code) and simply make the first action of the event to modify the value from 0 to 1.

    This way, it will not execute again.

    Also beware if you reset global variable, then this event will trigger again.

    Kyatric - Thanks! Adding another global variable helped fix the problem. Although I've also updated the capx for you to see what I was referring to.

  • Event 2 remove the "trigger once" condition and add an action "set Other = 1" and you're set.

  • Thanks!

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