basic save and load

0 favourites
  • 6 posts
From the Asset Store
Template for a generic save / load system, fully documented in comments and video
  • I've read the post about using web storage to save your game, but there are no instuctions on how to use that plugin. I have a global varibale"level_progress" and I'm setting the web storage to set session value to:

    key:level_progress

    value:level_progress

    on layout start.

    I'm guessing that I'm doing it wrong. Will it work on an offine output? or does it need to be posted to a server for the plugin to work?

  • The key should always be the same - it's like the address it looks at to save or load variables. Try

    key: "level"

    value: level_progress

    The way you have it now if level_progress is 5, you save the number 5 under the key 5. If you load a new game level_progress presumably starts at 0, so the plugin looks under the key 0 (which doesn't exist) and gets nothing back. So just make sure you use the same key for each value.

    'Session storage' also only lasts as long as the window is open - you probably want to use 'Local storage' which persists.

  • Thanks for the response, that makes sense, but it's still not working for me. Does the output need to be on a server to save? Here is the we storage section of my event sheet:

    <event-block>

                <conditions>

                   <condition id="-2" name="On start of layout" type="System" />

                </conditions>

                <actions>

                   <action id="0" name="Set local value" type="WebStorage">

                        <param id="0" name="Key">"save_level"</param>

                        <param id="1" name="Value">level_progress</param>

                   </action>

                </actions>

            </event-block>

    Not sure if that helps. I set it the way you said. Should this happen "at the start of layout"?(meaning is that causing a problem?)

  • No, it saves to the user's computer, not the server. But if you set level_progress on start of layout, it overwrites whatever was saved there before!

    You should only save a value when the user wants to save their progress. Then, you should read (not set) the value on startup.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I still can't get it to work. I guess I need a sample file or a quick step by step. I must be the only one on this website that can't save a game, so if anyone would be so kind as to send me a sample project with a save game feature that would be wonderful.

  • I got it to work now, thanks for all the advice. I will post a basic step by step so any other noobs out there don't have to bother you.

    Global variable:level_progress

    system-on end of layout-WebStorage-Set local key "save" to level_progress

    system-on start of layout-system-Set level_progress to WebStorage.LocalValue("save")

    this should work as an auto save for any game with levels.

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