Hi,
Events can hold data, that's very convenient for your case: check the following pair actions:
https://hutonggames.fogbugz.com/default.asp?W531https://hutonggames.fogbugz.com/default.asp?W530----- CASE:
FSM 1 : the fsm from where you want to increment the value
FSM 2 : the fsm declaring the variable "my int" and another var "_add_" holding the amount to add
------
You could do the following:
in FSM 1 send an event "ADD TO MY INT " with that event int data set to the amount you want to add.
in FSM 2 catch that event, get that int, store it in second temp variable like "_add_" and then you are all local and access "my int" easily by simply adding "_add_" to "my int" ( that's when I'd like playmaker to expose the ability to declare variables public or local... it totally make sense in such situation I feel)
The thing to be careful then is that you need to have FSM 2 ready to accept that "ADD TO MY INT" anytime and not have other potential process going on at the same time.
--------------
The other solution ( maybe less efficient cause always running) is to use the same fsms and variable config and set the "_add_" directly from FSM 1 and have FSM 2 checking constantly for "_add_" change and if change, add and reset "_add_" automatically.
If you have lots happening in FSM 2, all this is not really possible without refactoring. In this situation ( likely the case), I create a "meta data" fsm that simply holds variable and the events and actions required to manage them ( making sure they can not interfere with each other). I create as many and sometime one per variable so that it's totally isolated and can run constant checks and/or react to events without breaking any process. Very powerful, it's very much like implementing getter and setter function in conventional codes, you can react to variable changes by using events instead of directly change the variable from external places. This allow better encapsulation and provide a much higher level of flexibility and power all around.
--------------
The last option is to write a custom action that add to ints from any fsm together.
I did that for boolean tests and such. please find it attached with this post. I have also made a post on the right forum for easy referencing:
http://hutonggames.com/playmakerforum/index.php?topic=353.0 If you have any questions or needs clarifications, don't hesitate
Bye,
Jean