Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: VascBogdan on March 12, 2015, 09:22:30 AM

Title: PlayMaker Int & Float variables into JS
Post by: VascBogdan on March 12, 2015, 09:22:30 AM
I have seen some posts where people asked to get variables into C# scrips, but I need them into JavaScript if possible. My variable is called "currentWave", a float.
I am pretty bad at complicate scripting, so can someone please write me a script for that, so I can have it as an example for future needs ? Is it much different for strings or anything else ?
Title: Re: PlayMaker Int & Float variables into JS
Post by: Lane on March 12, 2015, 09:47:24 AM
You can use Get property and Set property to access variables in scripts.

Title: Re: PlayMaker Int & Float variables into JS
Post by: VascBogdan on March 12, 2015, 10:21:18 AM
I don't think this is exactly what I wanted.
I have to import in my JS script, somehow, a variable from an FSM (or globally, doesn't really matter).
I have seen 30 minutes ago a post with a script for doing this, but it was for C# ( it is this: http://hutonggames.com/playmakerforum/index.php?topic=2510.0 (http://hutonggames.com/playmakerforum/index.php?topic=2510.0) ).
Title: Re: PlayMaker Int & Float variables into JS
Post by: Lane on March 12, 2015, 10:40:59 AM
You can manipulate variables in scripts with the Get/Set Property actions. It works either direction, FSM>Script or Script<FSM.

How does that not meet your needs here, specifically?
Title: Re: PlayMaker Int & Float variables into JS
Post by: VascBogdan on March 12, 2015, 11:24:50 AM
Well I don't exactly know how to use it properly. Well, what I need is to change a UI text (not GUI). You know I asked for help for this GUI-UI thing, but the NGUI was pretty hard for me to handle, and I find it easier to use "import UI.Text" in a JS, and just change the text like that. I have an empty gameobject where I calculate the current wave/time etc., so I just want to take somehow these values and change a text by them. Is this still possible to solve with this set/get property ? If yes, can you please be more specific, I don't really understand how to use it (I did check the video you gave me but it doesn't really helped me, at all).
Title: Re: PlayMaker Int & Float variables into JS
Post by: Lane on March 12, 2015, 11:36:17 AM
Thats basically exactly what Get/Set Property is for.

The video shows precisely how the process works, you can apply the same workflow to a UI Text component and just target the Text>String property in the action.
Title: Re: PlayMaker Int & Float variables into JS
Post by: VascBogdan on March 12, 2015, 12:09:56 PM
I got it now, but: when running the game it gives me an error telling me that the object WHERE I PUT my Set Property needs a GUI. Well, if I add the GUI to my Text again, I will go back the my old story... I need it for UI, not GUI. I don't understand why this simple thing is so confusing for me.
Title: Re: PlayMaker Int & Float variables into JS
Post by: Lane on March 12, 2015, 12:52:23 PM
Cab you share some screenshots?
Title: Re: PlayMaker Int & Float variables into JS
Post by: VascBogdan on March 12, 2015, 03:19:26 PM
(http://s30.postimg.org/va3hprrup/image.png)

(http://s30.postimg.org/3o0q538ht/image.png)


I disabled the GUI from my Text, but even if it is enabled, doesn't help with anything. In-game, the text remains "3", not blank. The random names of the variables (cs1, c1ts etc.) are just temporary, until I solve the problem.
Title: Re: PlayMaker Int & Float variables into JS
Post by: Lane on March 12, 2015, 03:58:08 PM
Remove the guiText component...

guiText is not UI Text. You are using UI Text.

With Get/Set Property you must Target the Component, not the GameObject. The video explains exactly how to do it. If the Component is not on the same gameobject as the FSM then you must Lock the graph view and then select the gameobject that has the target component (UI Text).

If it says GUI and not UI, then it is not what you want.
Title: Re: PlayMaker Int & Float variables into JS
Post by: VascBogdan on March 13, 2015, 07:59:07 AM
Yes, this was it. I don't know why Jean recommended me the NGUI thing because Set property seems easy (now that I know how to use it).