How do I save and load files during runtime?

0 favourites
  • 2 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • Hello all,

    I have a simple project to make an editor where the player can save load levels during runtime. I had previously attempted this by just saving the tilemap json data, which the player could copy/paste (as a string) to save and load.

    can find here - https://lootbndt.itch.io/crt-level-editor

    Im not technical at all, so a lot of the background stuff that happens goes over my head.

    The ideal solution would have the editor provide a file on save, then having the ability to load the level using the file during runtime.

    Any ideas/direction to something similar would be great. Big inspirations are 'bisty' and the 'fantasy consoles', very cool!

    gifs for fun!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello all,

    I have a simple project to make an editor where the player can save load levels during runtime. I had previously attempted this by just saving the tilemap json data, which the player could copy/paste (as a string) to save and load.

    can find here - https://lootbndt.itch.io/crt-level-editor

    Im not technical at all, so a lot of the background stuff that happens goes over my head.

    The ideal solution would have the editor provide a file on save, then having the ability to load the level using the file during runtime.

    Any ideas/direction to something similar would be great. Big inspirations are 'bisty' and the 'fantasy consoles', very cool!

    gifs for fun!

    Making a save functionality is somewhat difficult to explain as it involve a lot of things and there might be different ways to do it, I think. i made a save/load functionality a long time ago for a program, so I might not remember exactly how I did it. But from what i do remember you can use NWjs to do it. Unfortunately it is not as straight forward as it might sound.

    But basically it goes like this:

    1. Make the file with NWjs

    2. When the file is created you can write/append to it using NWjs, so you write all the information for each object you need to store, to the file.

    3. To load the data from the file you can use the AJAX functionality combined with the tokenats system commands in C2 which allow you to extract specific data from the file, which you can then apply to objects.

    To go into a lot of details would make this a very long post. So I would suggest reading these in the manual and make some small tests in a separate program just trying to save and load data. Its not as difficult as it might sound, its simply that it can seem a bit confusing a first.

    NWjs (To create and write to files)

    https://www.scirra.com/manual/162/nwjs

    AJAX (To load files)

    https://www.scirra.com/manual/107/ajax

    Tokennat

    tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

    tokencount(src, separator)

    Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3.

    These are extracted from here: https://www.scirra.com/manual/126/system-expressions

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