SaveStateJSON Question

0 favourites
  • 6 posts
  • I apologize if this has been covered, but I haven't been able to find a straightforward answer after days of searching and playing around in Construct.

    I'm building a game that will be integrated into a Learning Management System (LMS), so I'm using a custom SCORM plugin since players will be high school students who are logged into their own accounts. They won't always be using the same computer/device, so local storage isn't a great option to save their progress in a game.

    How can I export the string of JSON of the saved progress/state? I bought this template (https://www.scirra.com/store/royalty-free-game-templates/json-export-import-encryption-1191), but it doesn't seem to export JSON string of the saved state/progress. Ideally, they'll click/press a save button and it'll send the current game state to our LMS and then when they log in again, they'll be able to load their last progress. I just don't know where that string of JSON goes when you use the built-in "Save" function in Construct 2.

    I can't seem to find solid documentation or tutorials on how to use "SaveStateJSON" and "Load from JSON", so any help would be greatly appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • SaveStateJSON should be available in "On save completed" event. So you need to save the game, wait for "On save completed" event to trigger, and then send SaveStateJSON string to LMS.

    To load - request JSON string from LMS, put it into a variable. Then use "Load from JSON".

  • I'm a bit confused now, with SCORM you would be talking to an API file with JavaScript to pass get and set variables, there's no JSON in SCORM. If you're talking to an LRS using the xAPI then that's a different matter, for it DOES use JSON for its data stream. It seems you're talking apples and oranges here, has anyone actually communicated with a SCORM API to pass Construct 3 game data to an LMS????

  • There is a SCORM Plugin available: construct.net/en/construct-2/addons/85/c2-scorm-plugin/documentation

    However, our LMS is proprietary and was written by my manager, so he wrote his own Construct 2 plugin for me to use. Unfortunately, I don't know much about AJAX/JSON/PHP/API/LMS Development and he doesn't know much about Construct 2 or game development, so it's just been us trying to piece together a working game that will work on the LMS and save a student's progress.

    Ideally, when the student clicks the Exit button it will automatically save their progress, so they don't need to worry about manually saving progress. Here's what I've done so far that seems to work initially (I haven't done through testing yet).

    Menu Screen

    Game Screen

  • I believe your mistake is that you don't wait for "On save complete" event. Saving takes some time and SaveStateJSON expression is not available immediately after you execute "Save game" action.

    So instead of the "ExitMenu" function use "On save complete" event.

  • I believe your mistake is that you don't wait for "On save complete" event. Saving takes some time and SaveStateJSON expression is not available immediately after you execute "Save game" action.

    So instead of the "ExitMenu" function use "On save complete" event.

    Sorry, I uploaded an older screenshot from my testing yesterday, I updated the post with what I have now. You're correct, I got rid of the ExitMenu function and put it all in On Save Complete. Thanks for your help, just the "on save complete" piece advice got me at a good spot!

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