How do I create array with dictionary?

0 favourites
  • 2 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello! It's my first attempt to use a dictionary for collecting some data.

    I would like to count every time the player manually restarts (like pressing a button) or dies from the game in that specific layout, for each layout in the game. Ex:


    Restarts: 5

    death: 2


    Restarts: 3

    death: 1

    and so on. So in a sense, it's an array.

    Since it's been a while I made even the simplest database ever, I was wondering if it's possible to use the dictionary for this purpose. Once the game is ended, it will release a downloadable .json file with the written data.

    This is all I have to say that doesn't make the question more confused.

    Here below some of my experiments:

    Before posting this topic, I tried following my instinct and worked it out with trial-and-error. The project partially works: In each layout, the game creates a new dictionary with the name of the room on it, plus all the details like I mentioned before. There are two problems, however: If you go to the next layout, the first dictionary may take the name of the next layout. Furthermore, the data from the first dictionary continue to get collected even after passing through another layout.

    When I extract the text file, the data from the layouts I played are redundant.

    What do you think I should do next?

    Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Are you using multiple dictionary objects? Or one dictionary object with multiple instances? This will make it more difficult to export json file with the results.

    I suggest you use one dictionary and create unique key names for each level in it. For example:

    level1_restarts: 5
    level1_deaths: 4
    level2_restarts: 2
    level2_deaths: 1
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)