playMaker

Author Topic: Use playMaker global variable in javascript  (Read 2328 times)

Sly

  • Full Member
  • ***
  • Posts: 123
Use playMaker global variable in javascript
« on: August 12, 2013, 04:10:09 PM »
Hello,

I wonder how to access a global variable (and inverse) in a javascript script.
I found some topic about that but it was for C sharp.

Can someone give me the syntaxe about how access my variable (in the two ways, if possible)?

Thanks in advance  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Use playMaker global variable in javascript
« Reply #1 on: August 14, 2013, 05:05:31 AM »
Hi,

 here it is:

Code: [Select]
#pragma strict
import HutongGames.PlayMaker;

function Start () {

// get the global variable pointer
var _globalstring:FsmString = FsmVariables.GlobalVariables.FindFsmString("global string");

// output its value
Debug.Log(_globalstring.Value);
 
  // set a new value
_globalstring.Value = "new value";
 
  // coutput the new value. Also check in the Global variable browser, the new value will be displaed there too.
Debug.Log(_globalstring.Value);
 
}

bye,

Jean