Trigger once at start of layout

Get help using Construct 2

Post » Fri Sep 06, 2013 7:24 am

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.
B
41
S
12
G
1
Posts: 540
Reputation: 4,188

Post » Fri Sep 06, 2013 7:55 am

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".
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Fri Sep 06, 2013 8:12 am

@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.
B
41
S
12
G
1
Posts: 540
Reputation: 4,188

Post » Fri Sep 06, 2013 7:29 pm

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.ome6a17172013-09-07 03:56:37
B
41
S
12
G
1
Posts: 540
Reputation: 4,188

Post » Sat Sep 07, 2013 3:26 am

Shameless bump.
B
41
S
12
G
1
Posts: 540
Reputation: 4,188

Post » Sat Sep 07, 2013 3:52 am

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.Kyatric2013-09-07 03:54:40
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
293
S
117
G
96
Posts: 7,310
Reputation: 71,069

Post » Sat Sep 07, 2013 4:15 am

[QUOTE=Kyatric] 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.[/QUOTE]

@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.
B
41
S
12
G
1
Posts: 540
Reputation: 4,188

Post » Sat Sep 07, 2013 11:53 am

Event 2 remove the "trigger once" condition and add an action "set Other = 1" and you're set.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
293
S
117
G
96
Posts: 7,310
Reputation: 71,069

Post » Sat Sep 07, 2013 8:16 pm

Thanks!
B
41
S
12
G
1
Posts: 540
Reputation: 4,188


Return to How do I....?

Who is online

Users browsing this forum: roracle and 7 guests