playMaker

Author Topic: Is there a way to truly RESET the game - variables everything to start state?  (Read 2323 times)

createasaurus

  • Full Member
  • ***
  • Posts: 146
I'd like the player able to "Exit Game to Title Screen."

Right now, I've been trying to accomplish this by manually resetting all the variables and everything and then loading the Title screen... BUT there seems to be too much to keep track of doing it this way.  I keep running into bugs because I'm missing things.

I'd like the game to simply do a TRUE RESET at this point.  I'm hoping there is a way to do this.

Thoughts?
Thank you!!

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
In order to deal with that I've been storing my variables in hash tables/array lists- when the game starts the data that is needed is for the fsm's is loaded from the hash/arrays into fsm variables for each fsm-

In order to clear the data- you just clear the arrays/hashes when the game is over-

So if the array/hash data is not saved then the data that populates the fsm var's is the default-

To save I'm using Easy Save to save the hash/array data-

There's a lot of hashes/arrays to save but they are all in the same place and easy to manage like that-

I also set it up that way so I can populate the hashes/arrays with game data from xml files using Datamaker
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Lars Steenhoff

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 46
Nice tips,
it does sound a little complicated for a common problem, perhaps there could be an action made to save all fsm variables states and reset them when needed.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
I'd like to add built in support for this.

In the meantime, if any coders want to take a stab at custom actions, FsmVariables has a copy constructor and apply methods that should make this fairly easy:
Code: [Select]
// save variable values
var savedVariables = new FsmVariables(Fsm.Variables);

// restore variable values
Fsm.Variables.ApplyVariableValues(savedVariables);

You'd have to store the saved variables in a dictionary to lookup the variables for a given Fsm.

Or maybe this is already on the Ecosytem... it's hard to keep up! :)
« Last Edit: February 24, 2016, 07:47:20 PM by Alex Chouls »