playMaker

Author Topic: Best way to keep track of hundreds of variables.  (Read 2742 times)

createasaurus

  • Full Member
  • ***
  • Posts: 146
Best way to keep track of hundreds of variables.
« on: September 28, 2014, 06:51:27 AM »
In my levels that the player can revisit, there are hundreds of pickups.  I'd like to keep track of the pickups, so on level reload, they are there/or not there on return.  Is there a best practice to achieve this?  Should each object simply have a (Am I'm collected?) variable in their start state?  And then store each one individually in a (do not destroy FSM) for level loads, and then again in player prefs during save/load game?  Or is there some sort of efficient list system in PlayMaker to keep track of things?  Or is what I'm attempting just a bad idea?  I'm just looking for general advice.  Thank you.

Details:  I will have 5 levels, each will have about 500 picks ups.  This is for counsel development.  This is my first game, so I just don't know what to expect performance wise.  I just want to make sure I'm on the right track going in.  Thanks again.
« Last Edit: October 04, 2014, 07:12:03 AM by createasaurus »

TheBadFeeling

  • Junior Playmaker
  • **
  • Posts: 66
Re: Best way to keep track of hundreds of variables.
« Reply #1 on: September 28, 2014, 08:13:51 AM »
Use lists.

Each time a collectible is picked up, add its name (or ID) to a global list called theseItemsHaveBeenPickedUp (or inventory if that's the kind you need).

Then, let each item begin with checking if it is already in the list. If it is, have it deactivate itself. If it's not - well then it just sits there, ready to be picked up.  :D

If you have not done so already, you need to install the Arraymaker actions in order to use lists. Get them at https://hutonggames.fogbugz.com/default.asp?W715

/Bad
The Force is with you, young Playmaker – but you are not a C# senpai yet.

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Best way to keep track of hundreds of variables.
« Reply #2 on: September 28, 2014, 12:35:47 PM »
Quote
If you have not done so already, you need to install the Arraymaker actions in order to use lists. Get them at https://hutonggames.fogbugz.com/default.asp?W715

Perfect.  Thank you.  I was hoping there was something like this.  I will install Arrymaker and learn more from there.

createasaurus

  • Full Member
  • ***
  • Posts: 146
Best way to keep track of hundreds of variables.
« Reply #3 on: October 04, 2014, 07:10:42 AM »
Alright, I'm looking for a sanity check here.  Please somebody stop me if I'm making a bad decision.

For managing and saving variables in my (very first) game, I've decided to stick with pure PlayerPrefs and forgo ArrayMaker.

Here is why:
1. I think PlayerPrefs can handle my needs alone.  Basically I have 500 objects in the game and 3 Save File Slots, total 1500 things to save.  I only need to know one thing about each object - "has it been destroyed yet  or not?"  On each level load, about 50 objects will simply check if they should exist against PlayerPrefs.  I think PlayerPrefs can handle this.  Correct?

2. This is my first game and I'm trying to keep things as simple as possible.  I've spent a couple days studying the ArrayMaker examples, tutorials, documentation + experimenting.  I've had some success and it seems to have great potential, BUT, quite honestly at my beginner level, it is still above my head to fully understand / control.

Conclusion:  I'll stick with the basics (no ArrayMaker) for this first game of mine... and cross my fingers there will not be significant performance issues...  Am I setting myself up for performance issues???  Please stop me if I am.  Many thanks.
« Last Edit: October 04, 2014, 07:16:42 AM by createasaurus »

TheBadFeeling

  • Junior Playmaker
  • **
  • Posts: 66
Re: Best way to keep track of hundreds of variables.
« Reply #4 on: October 05, 2014, 05:52:44 AM »
I'm a beginner like you, and was a bit reluctant to use ArrayMaker myself, because it was hard to get started with -- but right now I'm very glad I did. It's a lot easier for me to have the inventory-list because I also use an inventory in my current game, so it's nice to have the list handy.

You do as you please, I haven't tried to store that many varialbles in prefs, but I'm told it can hold thousands before you hit the ceiling cap (1MB is it?). My only concern is the time delay to load so many variables from prefs, but I lack the experience to know if it's a problem or not.
The Force is with you, young Playmaker – but you are not a C# senpai yet.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Best way to keep track of hundreds of variables.
« Reply #5 on: October 05, 2014, 06:44:50 AM »
Hi,

 I think you are getting confused between what ArrayMaker and PlayePrefs are.

 ArrayMaker doesn't save anything on the user's device, PlayerPrefs do, so you need player prefs AND arrayMaker.

ArrayMaker only let you define variable in the editor and manipulate them at runtime. PlayerPrefs only load and save data to persists on the user's device.

 Now, for large amount of data, indeed I don't really ( that's personal) rely on PlayerPrefs, but rather use XmlMaker or some database to store large amount of data.

 Bye,

 Jean