How do I update project files with new information?

0 favourites
  • 5 posts
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • Hi everyone,

    I have a few dictionaries and arrays in the Files folder of my project. They were created inside C3 not imported.

    Now the information I get from those files are loaded into their respective objects at runtime. The information gets updated as the game is played.

    What I want to do is write back the information (the new updated one) into the files I read them from previously. Is there a way to do that?

    Thanks.

    Tagged:

  • As far as I know there isn't, unless someone else corrects me. But I'm guessing you're asking that because the user can change the contents during the game. I think the way you should look at this, is that the design time info is like a starting point. where you start from when starting off with the game. I think you should use the local storage plugin to save the dictionary/arrays, and on start of layout check: if the item exists in local storage, load it from local storage ELSE load it using ajax from the project file.

    but maybe I don't understand the use case well, so hope it helps?

  • As far as I know there isn't, unless someone else corrects me. But I'm guessing you're asking that because the user can change the contents during the game. I think the way you should look at this, is that the design time info is like a starting point. where you start from when starting off with the game. I think you should use the local storage plugin to save the dictionary/arrays, and on start of layout check: if the item exists in local storage, load it from local storage ELSE load it using ajax from the project file.

    but maybe I don't understand the use case well, so hope it helps?

    I think you got it right. I just wanted to save back values to the file after loading it. So say I loaded values:

    Key = potions, value = 0.

    Then player acquired 10 potions. So I save that back into the same file:

    key = potions, value = 10.

    So next time the player launches the game, the amount of potions they'd have is 10.

    I guess what you suggested should work -- will the system "Save" and "Load" actions work here too? Because I care more about saving the data than "where" to save it or must I use the local storage?

    Thanks.

  • Hi, Save/Load will work, but the disadvantage is that you will save all of the rest too, not just the array/dictionary. Unless you assign the "nosave" behavior to all object types.

    Check my youtube channel, it's filled with examples; for example this one. Where I use save/load, but on top of that also save load a dictionary to local storage. So both systems combined so to speak

    youtu.be/1EEESGQu28M

    A lot of other tutorials load stuff from arrays and dictionaries, so maybe that can help in some way too. check them out

    cheers!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, Save/Load will work, but the disadvantage is that you will save all of the rest too, not just the array/dictionary. Unless you assign the "nosave" behavior to all object types.

    Check my youtube channel, it's filled with examples; for example this one. Where I use save/load, but on top of that also save load a dictionary to local storage. So both systems combined so to speak

    https://youtu.be/1EEESGQu28M

    A lot of other tutorials load stuff from arrays and dictionaries, so maybe that can help in some way too. check them out

    cheers!

    Ah, that makes sense. Forgot it saves everything. Thanks for the link that is an interesting tutorial. Learned a few things from it :D. Thank you again. I'll check the other videos!

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