playMaker

Author Topic: PlayMaker Int & Float variables into JS  (Read 3826 times)

VascBogdan

  • Full Member
  • ***
  • Posts: 118
PlayMaker Int & Float variables into JS
« 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 ?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: PlayMaker Int & Float variables into JS
« Reply #1 on: March 12, 2015, 09:47:24 AM »
You can use Get property and Set property to access variables in scripts.

Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

VascBogdan

  • Full Member
  • ***
  • Posts: 118
Re: PlayMaker Int & Float variables into JS
« Reply #2 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 ).

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: PlayMaker Int & Float variables into JS
« Reply #3 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?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

VascBogdan

  • Full Member
  • ***
  • Posts: 118
Re: PlayMaker Int & Float variables into JS
« Reply #4 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).

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: PlayMaker Int & Float variables into JS
« Reply #5 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

VascBogdan

  • Full Member
  • ***
  • Posts: 118
Re: PlayMaker Int & Float variables into JS
« Reply #6 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.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: PlayMaker Int & Float variables into JS
« Reply #7 on: March 12, 2015, 12:52:23 PM »
Cab you share some screenshots?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

VascBogdan

  • Full Member
  • ***
  • Posts: 118
Re: PlayMaker Int & Float variables into JS
« Reply #8 on: March 12, 2015, 03:19:26 PM »





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.
« Last Edit: March 12, 2015, 03:21:02 PM by VascBogdan »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: PlayMaker Int & Float variables into JS
« Reply #9 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

VascBogdan

  • Full Member
  • ***
  • Posts: 118
Re: PlayMaker Int & Float variables into JS
« Reply #10 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).