playMaker

Author Topic: Reset all variables  (Read 4720 times)

bpritchard

  • Playmaker Newbie
  • *
  • Posts: 11
Reset all variables
« on: July 01, 2012, 07:07:28 PM »
We're trying to figure out if there's a function or way of resetting ALL the global variables back to their default or null states based on a case switch... right now we have a player based game and if multiple users log in the variables aren't getting reset per user, so mini games are retaining their states across users. The simplest thing for us to do at this point would be to, on user change, reset all mini game states (aka global variables). Our games don't NEED to start any information, as they are either win or no win kinda games (they should reset fully at start anyways).

Any help would be AWESOME! THanks!
Bryan

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Reset all variables
« Reply #1 on: July 02, 2012, 02:20:36 AM »
Hi,

 I am not aware of any current solution to reset all global vars.

 I would suggest you move away from global variables to host your game values and create a FSM hosting them values, it makes accessing variables slightly more akward, but then your mini game state can be created as a prefab that you can then destroy, reinstanciate etc etc, thus achieving what you want.

The quickest solution currently is to have a FSM responsible for resetting your global variables, you would create and call a global event "RESET MINIGAME" or something and one by one you would set global variables to their default. How many global vars you would have to reset?

Bye,

 Jean

bpritchard

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Reset all variables
« Reply #2 on: July 02, 2012, 09:58:43 AM »
unfortunately thats how all of our mini games are setup and there's no real exit strategy at this point. :) But, if there's a way we can get to all the globals, loop through them and set them to a "default" value... that would work for our current purposes. Is this something thats possible?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Reset all variables
« Reply #3 on: July 04, 2012, 03:10:25 AM »
Hi,

 For this you would need some kind of small system built, because when resetting your globals what kind of values would you set? null or what was set during editing time?

In all cases, writing custom actions to achieve this is possible. Do you have scripting knowledge?

 bye,

 Jean

bpritchard

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Reset all variables
« Reply #4 on: July 04, 2012, 09:01:25 AM »
thats what we kinda figured... we ended up making a default set of params on the main menu that get initiated when the user taps on the new user play button. Works like a charm.

We do have quite a bit of scripting/programming knowledge at hand.. we've just started digging into that side of playmaker so its a little foreign right now.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Reset all variables
« Reply #5 on: July 05, 2012, 03:36:13 AM »
Hi,

 ok, so yes, the api will give you access to all the global variables, per type.

Within the context of an action, you can query:

Code: [Select]
FsmVariables.GlobalVariables.GetFsmBool("my global bool");
this will give you a pointer to that global boolean "my global bool" and then you can set or get its value

If you need a working example or a custom action, let me know, so that you can get started.

bye,

 Jean