How do I save and load arrays

0 favourites
  • 6 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi, is there a way to save a lot of arrays?

    the idea is the next:

    In this game the player can move objects on the floor and put them in any location.

    Each time the player touches a specific object the level is stored in an array so you can load it later.

    The porblem is that I want to be able to load the array not only in this session of the game, is there any way to save and load the arrays in a text file or something?

    Another thing, the array size is very large almost 50x50

    Thanks so much for your help!!!

  • Check the manual - https://www.scirra.com/manual/125/system-actions

    Scroll down just past halfway.. Save & Load.

    That's the very easy way.

    The other way is to save the array as JSON, then you can load it back in. More fexibility this way.

  • "Another thing, the array size is very large almost 50x50"

    Just noticed you said that. Believe me, 50x50 isn't large at all

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, thanks for the fast response.

    As i was saying (sorry for my bad english) i want this arrays to be NOT in a local save. i want the ability to share this arrays so other players can load/download them and play the levels.

    i was thinking something like ajax y json but the problem is i dont know how to upload the levels(arrays) and download them... is there any tutorials or examples you know about?

  • Yeah json is the way to go then. https://www.scirra.com/tutorials/526/ho ... -savegames

    [quote:1kje7yul]Using the JSON data directly

    In both the On save complete and On load complete triggers, the system SaveStateJSON expression returns a string of all the JSON data for the savegame. Note the SaveStateJSON expression will return an empty string outside of these triggers; the triggers are your only opportunity to access the data directly.

    If you have your own server, it's possible to make shared savegames by posting the JSON data to the server with the AJAX object and storing it in a server database. Alternatively some platforms like Windows 8 and Clay.io allow you to store data for the logged in user, where it's shared anywhere they log in. This is a useful for allowing users to take savegames with them wherever they go.

    Once you get the JSON string back, you can load the game from it using the Load from JSON system action.

    I haven't messed with json stuff too much so I can't relaly help you with saving to a server and loading back from it. I can't see it being too difficult. Search the tutorials or the forums for json and I'm pretty sure you'll find some snippets <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

  • Yes Thats exactly what i need.. but i cant find an example or a real tutorial on how to do this.... Hope someone can help!

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