Hi,
I have the same feeling about how playmaker interfaces with scripts. I have too much boiler plate code and composition to build for my liking, tho I can live with it since I found a solution that I like
My approach when trying to solve exactly what you are willing to do is to create special functions within my existing script that accepts a fsm variable as parameter, and modify the parameter instead of simply sending the value via return
So it works like that:
in your script build/override a function so that it receives a fsm variable ( don't forget to add "using HutongGames.PlayMaker;" at the top of your script) :
void GetMoney(FsmFloat outFloat){
outFloat.Value = money;
}// GetMoney
in fsm, simply use the "sendMessage" action and select your fsm variable to pass as a parameter to the message. And there you have your money value transferred from a script to a fsm variable in one step without custom action.
I totally avoid making a custom action for each and every information I want to pass from existing script to fsm, that's a lot of work for nothing I feel, and it doesn't scale at all. Each time something new come out, you'll need to write yet a gain a custom action, that will be difficult to access amongst so many unrelated actions.
Now, there is another approach using eventsData I think. I haven't yet tested it fully, when I do I will edit this post, cause I think it's better because basically, script can send an event to playmaker and pass data with that event, which is very good practice. So instead of querying when needed the money value, it's when the money value changes that the script sends an event to the fsm with eventsData, so that in the fsm, you simply catch that event in a state and get the EventsData which is the money value.
Either way, I don't see yet a way to access script from fsm as we normally do with script-script access, so either way, with my current humble knowledge of things, your scripts needs to adapt and accommodate the playmaker factor or you need to write custom actions which is a lot of work.
I might over thinking and over complicating it and maybe there is a much much easier/nicer solution to this problem we have
Bye,
Jean