saving data simplified?

0 favourites
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Okay so I am trying to figure out how to save simple data in a game such as level progress and unlockables that are set to either true or false, or to a simple number. Like the equivelent of "Named Variable Object" or "ini++" in Multimedia Fusion. I want it to load it on the start of the game and check or create all the values. In MMF, I loaded the file, then set all the values to the value of themselves. for some reason that seemed to work, though it didn't make total sense (but simply loading the file didn't work). And then for example when the level is beat I want it to add 1 to a value such as "level1clear" (I add instead of set in case I want to keep track of how many times the level was cleared) and then save it.

    Is there a construct plugin that can do this? I tried "Dictionary", "Array" as well as the plugin that had node webkit exclusive features, but none of them did what I want. And to be clear I want the save file to be saved AUTOMATICALLY in the game's root folder and with a specific name, and not prompt me and ask me where to save it or what to name it. That reason is why JSON download for "Dictionary" didn't work for me as my method of saving the file.

  • Both dictionary and array objects can do this just fine. Save the data as a JSON string and use the node webkit object to write that to a file wherever you want. The manual contains all the info on this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Instead of saving to file,try saving to webstorage.

  • Both dictionary and array objects can do this just fine. Save the data as a JSON string and use the node webkit object to write that to a file wherever you want. The manual contains all the info on this.

    Can you please give me step by step instructions? I looked at those two objects really throughly and I really couldn't accomplish what I wanted.

    Instead of saving to file,try saving to webstorage.

    My game MUST be playable as an offline exe, so that's a definite no.

  • I think you might misunderstand how webstorage works.

  • I really do think that WebStorage should have its name changed. So many newcomers get the wrong impression from its name. Simply put: WebStorage can store data permanently to the user's hard drive.

    You should definitely read the manual entry on WS, as well the tutorials that cover saving game data using both the built-in system and WebStorage itself.

  • Thanks for explaining, but webstorage still doesn't look good to me. I don't want the save data to be associated with the browser AT ALL, even if it is offline. And I don't want the save data being deleted if cookies are cleared, and the manual says it does that. All I want to do is make a save file with a few simple variables saved, IN THE GAME'S ROOT FOLDER. I am gonna try the dictionary again. Some of my testing went wrong. I had it programmed to play sounds when the save data did different things but they weren't playing... and the problem turned out to be the sounds, not the data. So I am gonna try again the method of Dictionary + node webkit object, once I figure out why the sounds are not working. They were wav files and it said they were successfully converted to ogg...

    edit: the sounds work when playing it after exporting to node webkit, but not when testing it in chrome.

  • I don't want the save data to be associated with the browser AT ALL

    And I don't want the save data being deleted if cookies are cleared

    If you use Node-Webkit, it won't be.

  • > I don't want the save data to be associated with the browser AT ALL

    >

    > And I don't want the save data being deleted if cookies are cleared

    If you use Node-Webkit, it won't be.

    Will the save file be in the game's root folder?

    Also I want to know if I need a variable for the root folder, or if entering a file name with no path will automatically go to it? Game maker does the former but MMF does the latter.

    edit: Just for the record, I managed to save and load a key successfully with webstorage. However, I still do not know where the save file is located, or how to change or define that.

    I want the save file to be simple, and easily controlled by the player. I don't want them to have to hunt for it or go to appdata or anything. I want them to be able to back it up or copy it to another computer, or simply delete it if they want to reset the game's progress. And I strongly believe saving to the game's root folder is the easiest way to do that for them.

  • WS data is in the "OS:\Users\Username\AppData\Local\AppName\Local Storage" folder if you use Node-Webkit.

    If you need access to the files, or want to specify their folder, then I'd suggest creating a manual storage system using the Node-Webkit file management actions and expressions. Be sure to obfuscate the contents in some way, otherwise users will be able to simply edit their own save data.

  • f you need access to the files, or want to specify their folder, then I'd suggest creating a manual storage system using the Node-Webkit file management actions and expressions. Be sure to obfuscate the contents in some way, otherwise users will be able to simply edit their own save data.

    Sadly, I couldn't figure out how to use that object. It didn't seem as simple to use. Are there any tutorials?

    I have no clue how to obfuscate, either. In MMF, the contents were automatically obfuscated (only in Named Variable Object, not in ini++). I made one game using ini++ and its save file is editable.

  • If the plan is to write the files to the app folder then WebStorage is entirely useless; why are you guys pushing it so much?

    You basically want to do this:

    Make a global var called Root

    +Is in preview

    -Set Root to <Path to write files to>

    +Is NOT in preview

    -Set Root to NodeWebkit.AppFolder

    Then, if using a dictionary to store save data...

    +On Function "SaveGame" (or whatever)

    -Write file to Root & <File Name> with contents Dictionary.AsJSON

    The Root global var is used because, in preview, AppFolder returns the node webkit folder in the C2 install directory. More info here.

    (Note all this is from memory so you might want to check out the manual if there are any problems)

  • If the plan is to write the files to the app folder then WebStorage is entirely useless; why are you guys pushing it so much?

    You basically want to do this:

    >Make a global var called Root

    +Is in preview

    -Set Root to <Path to write files to>

    +Is NOT in preview

    -Set Root to NodeWebkit.AppFolder

    Then, if using a dictionary to store save data...

    +On Function "SaveGame" (or whatever)

    -Write file to Root & <File Name> with contents Dictionary.AsJSON

    OMG THANK YOU! I am going to try that now. I will let you know how it goes. :)

    edit: would you mind giving an equally helpful description of how to load it from the file when the game starts up?

  • Very simple! You just use the dictionary's "Load" action, then enter Root & <FileName>. The dictionary will then be exactly as it was when saving.

  • Very simple! You just use the dictionary's "Load" action, then enter Root & <FileName>. The dictionary will then be exactly as it was when saving.

    here's what I have got so far:

    <img src="http://biancagames.com/constructhelp1.png" border="0" />

    either the save or load isn't working, not sure which.

    Here's what happens.

    1. Press K. sound for key "one" <=0 plays.

    2. Press L. sound for saving plays, though I don't know if it actually saved. But it definitely added 1 to the key "one" because <see number 3>.

    3. Press K again. Sound for key "one" > 0 plays.

    4. Close game and reopen.

    5. Press K again. Sound for key one <=0 played, so it either didn't save or it didn't load. or both. :(

    edit: just realized that the file itself was not created, so it looks like it didn't save. Do I have to create the file manually?

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