playMaker

Author Topic: trying to modify globalVariable from script function  (Read 935 times)

mutoit

  • Playmaker Newbie
  • *
  • Posts: 25
trying to modify globalVariable from script function
« on: January 11, 2021, 12:41:01 PM »
Hi , i have 2 global int , i made some script funcion ,call it trying to operate with those variables but..nothing happend.

  • i used using HutongGames.PlayMaker;
    i declare 2 int variables
  • i try to get the variable ;
Code: [Select]
int playMakerCombustible;
    int playMakerMineral;


Code: [Select]
playMakerCombustible = FsmVariables.GlobalVariables.GetFsmInt("combustible").Value;
 playMakerMineral = FsmVariables.GlobalVariables.GetFsmInt("mineral").Value;
and call this method in playmaker ,is a simple rest
Code: [Select]
public void  OperacionCrafteo()
    {
      playMakerMineral -= requisitoCrafteo;
      playMakerCombustible -= requisitoCrafteo;
    }

Those variable never change his value
Thanks

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: trying to modify globalVariable from script function
« Reply #1 on: January 11, 2021, 03:15:50 PM »
Hi.
Have you tried using a Debug.Log to check if it receives a value?

mutoit

  • Playmaker Newbie
  • *
  • Posts: 25
Re: trying to modify globalVariable from script function
« Reply #2 on: January 11, 2021, 03:35:06 PM »
yes, he change in script, a little weird cos is jus the operation is just 10-10 but she gives me -10 but, he changes.
However ,the valor never change in playmaker.....

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: trying to modify globalVariable from script function
« Reply #3 on: January 12, 2021, 09:19:29 AM »
Hi.
To change in playmaker you need to update it on the global variable, as you only updated the variable in your script.

Code: [Select]
FsmVariables.GlobalVariables.GetFsmInt("mineral").Value = playMakerCombustible -= requisitoCrafteo;

mutoit

  • Playmaker Newbie
  • *
  • Posts: 25
Re: trying to modify globalVariable from script function
« Reply #4 on: January 18, 2021, 05:06:43 PM »
well that's what I'm trying but I don't know how to change the value in the global variable. What do I have to change in playmaker for this to happen?
« Last Edit: January 19, 2021, 04:39:03 AM by mutoit »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: trying to modify globalVariable from script function
« Reply #5 on: January 19, 2021, 05:56:10 AM »
hi.
Did you try the code line i posted?

mutoit

  • Playmaker Newbie
  • *
  • Posts: 25
Re: trying to modify globalVariable from script function
« Reply #6 on: January 20, 2021, 04:02:47 AM »
not now but i see, this must work, thanks ! I didn't even know that we can put 2 equalities on the same line :'(