playMaker

Author Topic: Diffculty setting a playmaker global value using javascrpting  (Read 3232 times)

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Diffculty setting a playmaker global value using javascrpting
« on: January 11, 2014, 03:00:43 PM »
Hi after searching I found this reference.

#pragma strict
import HutongGames.PlayMaker;

function Start () {

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

   // 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);*/
 
}

I had to comment out all of the areas as unity kept on saying there was issues.

I need to do this,

function TotalFramesUsed(FramesUsed : float){
  FrameNumber = FramesUsed;
 _globalstring.Value = "FramesUsed";
}

As you can tell i am not a coder but trying hard to learn.

If i could set the value of the _globalstring.Value i could then use playmaker to compair this value and do something.

Help please

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: Diffculty setting a playmaker global value using javascrpting
« Reply #1 on: January 11, 2014, 05:46:33 PM »
However this c# script is able to show the changed value:

using HutongGames.PlayMaker;
using UnityEngine;

public class AccessGlobals : MonoBehaviour
{
   public int anim_frames;
   
   private FsmInt FrameNumber;
   
   void Start ()
   {
      // Get the global fsm variables
      var globalVariables = FsmVariables.GlobalVariables;
      
      // Get the global numLives variable
      FrameNumber = globalVariables.GetFsmInt("Frame compairing");
      
      // Set the global variable to inspector value
      FrameNumber.Value = anim_frames;
   }
   
   void Update ()
   {
      // get the current global variable value to show in inspector
      anim_frames = FrameNumber.Value;
   }
}

How do I do this using java script??

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Diffculty setting a playmaker global value using javascrpting
« Reply #2 on: January 27, 2014, 04:16:31 AM »
Hi,

 not trying to avoid the question, but why not using c# then?

I never use javascript, but if you don't find the source of the problem,I'll have a look.


bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: Diffculty setting a playmaker global value using javascrpting
« Reply #3 on: January 28, 2014, 05:08:55 PM »
To be honest this has been solved for this specific request.

But i would still like to know the correct way to access play maker global variables using unity java script.

Please.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Diffculty setting a playmaker global value using javascrpting
« Reply #4 on: January 30, 2014, 06:47:20 AM »
Hi,

 This is the way:

Code: [Select]
#pragma strict

import HutongGames.PlayMaker;

function Start () {

 var _globalstring : FsmString = FsmVariables.GlobalVariables.FindFsmString("global string");
 
  Debug.Log(_globalstring.Value);
 
 _globalstring.Value += ", How are you?";
 
  Debug.Log(_globalstring.Value);
 
}

 Of maybe I misunderstand what you are trying to achieve?

Bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: Diffculty setting a playmaker global value using javascrpting
« Reply #5 on: January 30, 2014, 02:04:40 PM »
Thanks Jean, but can I get back to this at a later date?

I am busy at present but will come back

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Diffculty setting a playmaker global value using javascrpting
« Reply #6 on: January 30, 2014, 11:59:38 PM »
Hi,

 In your own time of course.

bye,

 Jean