Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Horror on January 31, 2013, 12:37:00 AM

Title: Use playMaker global variable in script?
Post by: Horror on January 31, 2013, 12:37:00 AM
Hi guys,

I'm trying to work out how I can access a global variable from playMaker in one of my scripts. I'm trying out the Geosophic leaderboards plugin but it has no playMaker support.

So basically, I have an int variable called ScoreCombineAll and I need the int score variable from my script to use that value. How would I manage this?

My expertise with this kind of scripting is... not good.

Cheers!

Code: [Select]
using UnityEngine;
using System.Collections;

public class GeosophicPostScores : MonoBehaviour {

int score = 0;
int leaderBoardSchema = 401;

void Start ()
{
GeosophicSDK.PostScore (score, leaderBoardSchema);
}
}
Title: Re: Use playMaker global variable in script?
Post by: jeanfabre on January 31, 2013, 12:54:17 AM
Hi,

 Basically, you do the following:

Code: [Select]
using HutongGames;
...
...
...
int score = PlayMakerGlobals.Instance.Variables.GetFsmInt("ScoreCombineAll").Value;


 yes?

bye,

 Jean
Title: Re: Use playMaker global variable in script?
Post by: Horror on January 31, 2013, 01:25:38 AM
Hi Jean

I'm getting this error:

Assets/Scripts/GeosophicPostScores.cs(12,21): error CS0029: Cannot implicitly convert type `HutongGames.PlayMaker.FsmInt' to `int'

Also, could you get an int variable from an FSM which is sharing the same object as the script?

Thanks!
Title: Re: Use playMaker global variable in script?
Post by: jeanfabre on January 31, 2013, 02:32:23 AM
D'oh, that's what you get with copy paste :)

add .Value to get to the int. like so:

Code: [Select]
int score = PlayMakerGlobals.Instance.Variables.GetFsmInt("ScoreCombineAll").Value;

bye,

 Jean
Title: Re: Use playMaker global variable in script?
Post by: Horror on January 31, 2013, 05:27:49 AM
Thanks Jean, it looks like you may have saved my arse yet again!
Title: Re: Use playMaker global variable in script?
Post by: jeanfabre on February 02, 2013, 03:34:02 PM
:)