playMaker

Author Topic: [SOLVED] C# global to playMaker global. How do i do it.  (Read 3234 times)

Martin-Vaupell

  • Junior Playmaker
  • **
  • Posts: 70
  • Creating CarbonDiOxide
    • Evisystems
[SOLVED] C# global to playMaker global. How do i do it.
« on: January 01, 2014, 01:06:12 PM »
First off are the globals from playMaker able to "communicate" with the scripts?

I'm playing around with different assets and trying to "plug" into them
right now I'm trying to hook into "lockpicking and hacking" asset from the store.

By default the asset is supplied with this, and it where i think i would want to hook in.

Code: [Select]
/// <summary>
/// Resets the dial sequence.
/// </summary>
public void Reset ()
{
// Count the dial reset value
dialResetCount += dialSpeed * Time.deltaTime;

// Reset the entire sequence if we move too much in the opposite direction
if( dialResetCount >= dialReset * 3.6f )
{
while( sequenceIndex > 0 )
{
sequenceIndex--;

direction *= -1;
}

dialResetCount = 0;

audio.PlayOneShot(soundReset);
}}



I have been working with globals across multiple FSM in playMaker and is great.
now with that experience i want to simple via this script above change a
global variable, maybe a bool just doing a flip or an int, changing a value counting failed attempts.

And then I'm going to make playMaker detect the change.


My problem is, how would i add,set,change a global var inside that function in such a way playMaker or anything else can read that var?




EDIT - UPDATE.


made a Bool for testing purposes, called "dialFail" default = false.
Ok added this to the script..


using HutongGames.PlayMaker;  //  at the top
and trying to figure out the FsmVariables....
tryed a few things, and ofcourse changed the global type accordingly.


1)
FsmVariables.GlobalVariables.BoolVariables("dialFail").....d.hmmm problems here..
I want to set or flip the bool value..
alternatly

2)
FsmVariables.GlobalVariables.   <---  SetInt ? ?  is that possible to set a
global int here.


3)
private string mytext = "test";            FsmVariables.GlobalsComponent.ToString("dialFail").mytext;
« Last Edit: January 07, 2014, 08:22:16 PM by VaupellAgainNoMailReceive »

Martin-Vaupell

  • Junior Playmaker
  • **
  • Posts: 70
  • Creating CarbonDiOxide
    • Evisystems
Re: C# global to playMaker global. How do i do it.
« Reply #1 on: January 02, 2014, 08:17:08 AM »

Well... Giving up using playMaker for this part.
switching to old School globals C#

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: C# global to playMaker global. How do i do it.
« Reply #2 on: January 02, 2014, 09:29:05 AM »
Hi,

 for the record, here is few line samples to do what you want.

Code: [Select]
// Get a PlayMaker global String named "MyGlobalString"
string _value = FsmVariables.GlobalVariables.GetFsmString("MyGlobalString").Value;

Code: [Select]
// Set a PlayMaker global String named "MyGlobalString"
FsmVariables.GlobalVariables.GetFsmString("MyGlobalString").Value = "hello";


Code: [Select]
// Flip a global boolean value
FsmBool _boolVariable = FsmVariables.GlobalVariables.GetFsmBool("MyGlobalBool");
_boolVariable.Value = !_boolVariable.Value;

Bye,

 Jean

Martin-Vaupell

  • Junior Playmaker
  • **
  • Posts: 70
  • Creating CarbonDiOxide
    • Evisystems
Re: C# global to playMaker global. How do i do it.
« Reply #3 on: January 02, 2014, 12:23:41 PM »
Hi,

 for the record, here is few line samples to do what you want.

Code: [Select]
// Get a PlayMaker global String named "MyGlobalString"
string _value = FsmVariables.GlobalVariables.GetFsmString("MyGlobalString").Value;

Code: [Select]
// Set a PlayMaker global String named "MyGlobalString"
FsmVariables.GlobalVariables.GetFsmString("MyGlobalString").Value = "hello";


Code: [Select]
// Flip a global boolean value
FsmBool _boolVariable = FsmVariables.GlobalVariables.GetFsmBool("MyGlobalBool");
_boolVariable.Value = !_boolVariable.Value;

Bye,

 Jean


Thx Jean..

I've looked at those, but was not using them because they where called "get" and the tooltip in monodev also said  "get"  not "set"..


But i will try them right away.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: C# global to playMaker global. How do i do it.
« Reply #4 on: January 02, 2014, 02:46:53 PM »
Hi,

 Yes, because FsmXXX are classes that wrapps all the different variable into its.Value property,

 so the bool switch is a very good example, you store the boolean Fsm variable and then get/set its value with the .Value

 Bye,

 Jean