Event listener for variables?

For developers using the Construct 2 Javascript SDK

Post » Wed Feb 13, 2013 3:23 am

What would be the best way to tie a variable change to a conditional event trigger? IE the window.addeventlistener which doesnt accept variable changes. How can I trigger an event on variable changes. So
var a = '1'

when var a changes to '2' trigger the condition.
B
68
S
21
G
15
Posts: 701
Reputation: 15,604

Post » Wed Feb 13, 2013 3:38 am

Never mind, I figured it out :) goofball moment
B
68
S
21
G
15
Posts: 701
Reputation: 15,604

Post » Mon Dec 09, 2013 5:31 pm

Could you tell me what you did to resolve? Maybe im dumb (probably) but I cant seem to think of a simple way to trigger something to happen ONCE when a variable changes. Like "On Click" type events..

Any time I use something like:

- If x = 3 then
   -- do "Action A"

it continually does Action A over and over and over again as long as x = 3... Other than manually programming another variable called "Action A complete" and then saying:

- if x = 3
- and action a is not complete
-- Do Action A

or maybe thats the only way?
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
23
S
7
G
3
Posts: 375
Reputation: 4,797

Post » Tue Dec 10, 2013 8:31 pm

I just finished a small behavior that does the trick, if anyone is interested.

On variable change plugin
B
3
Posts: 8
Reputation: 241

Post » Wed Dec 11, 2013 9:59 am

[QUOTE=80bit] Could you tell me what you did to resolve? Maybe im dumb (probably) but I cant seem to think of a simple way to trigger something to happen ONCE when a variable changes. Like "On Click" type events..

Any time I use something like:

- If x = 3 then
   -- do "Action A"

it continually does Action A over and over and over again as long as x = 3... Other than manually programming another variable called "Action A complete" and then saying:

- if x = 3
- and action a is not complete
-- Do Action A

or maybe thats the only way?[/QUOTE]

@80bit You can use the 'Trigger once while true' system condition maybe
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,094
Reputation: 15,355

Post » Wed Dec 11, 2013 5:55 pm

Aphrodite, actually, that was exactly what i needed - thank you so much! I found it in the manual yesterday after i posted and it has since changed my life haha. :) Much much easier now!
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
23
S
7
G
3
Posts: 375
Reputation: 4,797


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 2 guests