[Behavior] On instance variable change

Post your completed addons to share with the community

Post » Tue Dec 10, 2013 8:25 pm

I just finished writing a small behavior that triggers events when certain instance variable changes.

If there is someone interested in it I could upload it for public use.

So far it has the following functionality:

Enable/disable trigger events for specific/any variables
Add variable to watch list (with variable name)
Remove variable from watch list (with variable name)
Add all variables to watch list

Triggers events when:
A watched variable has changed (filters by variable name)
Any variable in the list has changed

Basically it handles two arrays, one with the variable names and another with the values (just as the instances do with their instance variables), on each tick, if it sees any change in a variable, it stores the latest value and triggers an event.

*Saves the hassle of duplicating instance variables to keep track of changes (value/oldValue)
*Easier to maintain
*Adds the possibility to add new trigger events to an object without writing new behaviors, just add an instance variable name with the name of the event and add 1 to that variable each time you want to trigger that event
B
3
Posts: 8
Reputation: 241

Post » Tue Dec 10, 2013 8:51 pm

I'm interested in this! :D Where do I sign?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
141
S
24
G
8
Posts: 790
Reputation: 15,119

Post » Wed Dec 11, 2013 1:34 pm

I will write the save/load code now and I will upload it as a c2addon then.
B
3
Posts: 8
Reputation: 241

Post » Wed Dec 11, 2013 2:40 pm

There you go, I haven't tested the save/load part of the code, but it should work without problems.

Please report any bugs.


Variable watcher 1.0
B
3
Posts: 8
Reputation: 241

Post » Wed Dec 11, 2013 5:56 pm

nevermind, it seems it doesn't work after exporting the project. I'm looking if this can be fixed...
B
3
Posts: 8
Reputation: 241

Post » Mon Jan 13, 2014 11:26 am

No new version?
B
20
S
3
Posts: 8
Reputation: 2,367

Post » Tue Oct 06, 2015 10:01 pm

broken link... I was planning on trying the old version without save and load...
Eat ALL THE BACON!
B
47
S
17
G
3
Posts: 290
Reputation: 5,070


Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 4 guests