Loading Slot when starting the Layout? (without ERROR)

0 favourites
  • 10 posts
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
  • Hi All,

    This is my current code:

    I'm not sure I understand the error since I'm still learning...

    When I hit "H" or "E" for testing, the console give me an error and it's not saving to the slot:

    I want the slot to be saved in the RELATIVE path of the project by default so I didn't put a path or directory but I'm not sure if it's anything to do with the error, just guessing.

    What am I doing wrong and how can I fix it?

    Thanks ahead! :)

    Tagged:

  • Don't use Save/Load actions for saving just the language setting. It's like making a full back up of your entire hard drive to save just one document.

    Besides, this can mess with your Undo system and other things. (which that error in the console log is probably about)

    Use Local Storage to save app settings.

  • Don't use Save/Load actions for saving just the language setting. It's like making a full back up of your entire hard drive to save just one document.

    Besides, this can mess with your Undo system and other things. (which that error in the console log is probably about)

    Use Local Storage to save app settings.

    Thanks for the great tip sensei!

    I never used Local Storage, it seems more complex than just "save slot" with a name...

    So I'm not sure what to do, I messed around trying to understand via the documents based on score but it just confused me when I got to my project goal (I know it shouldn't confuse me).

    So... I already have a Global Variable (string) that holds the languages, I'm not sure if I should make another one: "Default_Language" to use the local storage... or maybe no need..

    Here is just a mess (I didn't even finish playing with it) I wish it was simple as Save / Load Slot, but maybe it's not that confusing once I'll understand how it works (no thanks to the documents).

    Should I make each KEY as name of the language? what do I do next? That's a messed-up code that I'm showing you as I'm still playing around trying to understand how it works... sorry

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You did everything correctly.

    EDIT: Almost correctly! Key name should be "Language" or "Settings" or something similar (with quotes), not Language without quotes, because that's your variable.

    .

    You don't need "Get item" and "On item get" event. You can set language to LocalStorage.ItemValue in event 412.

    Also, if you need to save other settings values, instead of saving each one in a separate key, you can put them all into a dictionary and save the entire dictionary. See this comment:

    construct.net/en/forum/construct-3/how-do-i-8/solve-save-147873

  • I edited my comment, see above.

  • Thanks again Sensei, that's very helpful!

    I I'll probably have a look on Dictionary it may be useful for other settings all together (if I get the idea right) so I can use "Settings" in general.

    Anyway... it works, but it's very new to me and I want to be sure that it's correct, if you can approve it will be very helpful!

    I have some questions since I'm curious about how it works "behind the scene":

    1 - Is Local Storage creating a file based on the key name or something like .ini or .txt file?

    2 - Is it overwrite when I will use the same key?

    3 - Is it better than the system SAVE/LOAD? I wonder about the differences (speed, efficiency, etc..)

    4 - Can I save ANYTHING to Local Storage? or it's limited to specific things?

  • All looks good now.

    1 - Is Local Storage creating a file based on the key name or something like .ini or .txt file?

    With NWJS export - I'm not sure, probably a file somewhere in User folder. Stackoverflow suggests it's c:/Users/username/AppData/Local/AppName/Cache

    2 - Is it overwrite when I will use the same key?

    Yes.

    3 - Is it better than the system SAVE/LOAD?

    Save/Load saves everything (excluding only objects with NoSave behavior), LocalStorage only saves one piece of data.

    Like I said, the difference is like backing up your entire HDD and saving one document file.

    By the way, when you save an .alon file, Language variable is saved inside of it too. So when you load this file, language in the app may change. So you might want to restore language and other settings from LocalStorage after loading .alon files.

  • By the way, when you save an .alon file, Language variable is saved inside of it too. So when you load this file, language in the app may change. So you might want to restore language and other settings from LocalStorage after loading .alon files.

    OH Thanks, that's good to know!

    So... basically to keep the user language (whatever the user chose) not just when software starts but also after loading a project (file.alon) I should put the "Set Language" line after load is complete?

    Something like this will do the job? (I did a test, but want to be sure if it's efficient enough)

    I want the users to have their chosen language when software starts, but not having issues when save/load projects of course... I did a test and it works (from a quick test) but as you know I'm still a noob and any approve/suggestion is always appreciated!

    .

    EDIT:

    Nope... after few more tests, I noticed it's not working, it loads the language it saved last... :\

  • You need to request it again from Local Storage, using "Check item exist"

  • Thanks again!

    Looks like this works: (based on few tests)

    I hope it's on the correct order, after load is complete made more sense to me

    Do I need line 310 again? this event appears already on the original "Language" Group... or maybe I should enable it just in case?

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