Page 1 of 2
Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 3:39 pm
by Taka
Hi, I've just bought Dialogue System today and am fairly new to Unity as well, so excuse me if this seems like a dumb question but:
How can I Set a Playmaker global Int from within a conversation? For example: Add "xAmount" to "FsmInt".
My game stats are stored as playmaker global variables and would like to be able to edit them up quest completion.
I've tried making a GameObject containing an FSM that adds to an Int, then activating it in the Events section, but that didn't seem to work. And I'm not yet proficient enough at C# to figure out how to script it.
Any advice would be welcome!
Re: Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 3:55 pm
by Tony Li
Hi,
Thanks for buying the Dialogue System!
First import the
PlayMaker Support package. This will add a number
PlayMaker Lua functions that you can use in nodes'
Script fields.
For example, say the NPC heals the player to 100 Health. You've defined an int global variable named "Health". Set the node to:
- Dialogue Text: "Be healed!"
- Script: SetFsmInt("Health", 100)
Re: Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 3:59 pm
by Taka
That's great, thank you.
And if I wanted to add say 50 Health to my total would it be something like:
SetFsmInt("Health", +50)
or is that wrong? Again, sorry for the newbie questions.
Re: Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 4:58 pm
by Tony Li
No worries; happy to help! Use this:
Code: Select all
SetFsmInt("Health", GetFsmInt("Health") + 50))
In English, this sets Health to the current value of Health plus 50.
Re: Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 4:59 pm
by Taka
Awesome, thank you very much for the help!
Re: Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 6:26 pm
by Taka
I'm sorry, but I can't seem to get this code working.
I've tried several different variations of what you gave me but none of them work:
SetFsmInt("Money", GetFsmInt("Money") + 50))' threw exception 'Code has syntax errors:
SetFsmInt("Money", GetFsmInt("Money") + 50)' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
SetFsmInt(Money, GetFsmInt(Money) + 50)' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
I have installed the Playmaker support package. I had a look in the Actions folder that it created, but I couldn't see a script for "GetFsmInt" or "SetFsmInt". Is that intentional or am I missing them?
Re: Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 8:15 pm
by Tony Li
Sorry, I pasted the link to the documentation and then totally forgot to point out this important line:
"To make PlayMaker-specific Lua functions available, add the component Dialogue System PlayMaker Lua to your Dialogue Manager."
If you add that component to your Dialogue Manager, you should be good to go.
Re: Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 8:49 pm
by Taka
That's sorted it, thanks.
Re: Changing Playmaker Globals within a converstaion?
Posted: Sun Jul 29, 2018 9:36 pm
by Tony Li
Happy to help. Glad it's working now.
Re: Changing Playmaker Globals within a converstaion?
Posted: Tue Nov 06, 2018 9:49 am
by Jajamave
Hi I am also using dialogue systems with playmaker
I'm using lua to update playmaker global variables and have the lua script on my dialogue manager (just as you described) and it worked fine so far.
but when I switch between scenes the connection to the playmake Globals seems to fail and i get the same errors as if i didn't use the 'dialogue system playmaker lua' script:
Lua code 'SetFsmBool('HasLamp', true)' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
can you please help me?
(I recently added the 'easy safe' plugin to my project -might that be a problem?)