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.
www.h1k3.tech

We are here for you!
B
87
S
23
G
16
Posts: 715
Reputation: 16,835

Post » Wed Feb 13, 2013 3:38 am

Never mind, I figured it out :) goofball moment
www.h1k3.tech

We are here for you!
B
87
S
23
G
16
Posts: 715
Reputation: 16,835

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
27
S
8
G
3
Posts: 384
Reputation: 5,020

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
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

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
27
S
8
G
3
Posts: 384
Reputation: 5,020


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest