saving data characters

0 favourites
  • 4 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Friends. Good night.

    I have a doubt. I'm building a tower defense that in place of the towers will be characters.

    They will have attributes (attack strength, speed, stamina and defense), I can create a family for everyone to have that data.

    My doubt is how safe these information.

    I thought about using array, but it does not accept strings. And the dictionary, from what I understand, that would be a dictionary for each character / tower.

    This is the way? There are other means.

    Example of what I have to save.

    Name / attack strength / speed / stamina / defense

    pc1 /   1             / 2    / 1      / 3

    pc2 /   3             / 1    / 3      / 2

    pc3 /   2             / 3    / 2      / 4

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • But arrays do store strings...? I have used them several times for exactly this. But now that you can just save the game state, I prefer to just use variables on arrays. This works totally fine unless you are doing something like a CCG which requires in-depth information, like how many times an attack has had a modifier increase.

    EDIT: I should clarify that I prefer variables on arrays, then creating an instance of that array when a character is created and linking it to them (set instance variable 'id' to character 'uid'). It's a better method than storing the variables directly on the character for a number of reasons, like if the character gets destroyed but comes back later or you find you do want to store some info in an array later down the track, or maybe you want to store the data of each character for a debriefing layout.

  • Sorry friend, but I could not quite understand your method. Is there any example or any tutorial for esclerecer did this?

    Thank you for your attention.

  • Hm, no I haven't seen any. I learnt all this stuff myself and don't have any demos ready. But I will try to explain it:

    1. Create an array in the editor. Add an instance variable to it for each value you wish to store (attack, defence, etc.)

    2. On start of the game, destroy array (just to keep it clean)

    3. Condition 'on character created' > create object 'array'. Set value of array's instance variable 'id' (which you also include when creating the variables for the array) to 'character.uid'. Then set all other variables to the desired values.

    4. Whenever something affects 'character', pick the corresponding array by adding the condition 'array.id = character.uid'. Now alter the values of the array's variables asthough it was the character.

    This is a very simple way to do things that still allows more flexibility than storing the values directly on the character. If you think that you will need more control over the information, then yes also use the array's cells.

    I don't have time to fully explain my methods for that right now sorry, but essentially you just use 'push' to add a string value (say 'attack') on the X axis, then values on the Y axis (starting from 1, because 0 will be your string). Then you can do things like run loops for 'array.height' times, using local variables as counters to get the value for each cell under a string: array.At(array.indexOf("attack"),counter))

    That method is actually quite easy to use, just there is a lot of possibility so deciding the right ways of indexing and retrieving the information for your game will likely take some time and thought. Hope that helps!

    EDIT: Also in case you haven't noticed, I'm not a fan of using a single array for all the characters. I really can't see any reason to do it that way and many reasons why not to. So unless you have a very specific reason for doing so (and if you do I'd like to know why out of curiosity :) ), the main thing I suggest is to store values for each character in their own object.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)