saving data simplified?

Discussion and feedback on Construct 2

Post » Mon Feb 03, 2014 4:34 am

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.DialgaBrite2014-02-03 04:36:07
B
15
S
2
Posts: 103
Reputation: 1,178

Post » Mon Feb 03, 2014 6:39 am

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.MadFactory2014-02-03 06:40:17
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Mon Feb 03, 2014 7:15 am

Instead of saving to file,try saving to webstorage.
lennaert2014-02-03 07:15:34
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Mon Feb 03, 2014 4:05 pm

[QUOTE=MadFactory] 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.[/QUOTE]

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.

[QUOTE=lennaert] Instead of saving to file,try saving to webstorage.
[/QUOTE]

My game MUST be playable as an offline exe, so that's a definite no.
B
15
S
2
Posts: 103
Reputation: 1,178

Post » Mon Feb 03, 2014 4:15 pm

I think you might misunderstand how webstorage works.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Mon Feb 03, 2014 5:27 pm

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.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Mon Feb 03, 2014 6:18 pm

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.DialgaBrite2014-02-03 18:21:44
B
15
S
2
Posts: 103
Reputation: 1,178

Post » Mon Feb 03, 2014 6:38 pm

[QUOTE=DialgaBrite]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[/QUOTE]
If you use Node-Webkit, it won't be.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Mon Feb 03, 2014 6:46 pm

[QUOTE=GeometriX] [QUOTE=DialgaBrite]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[/QUOTE]
If you use Node-Webkit, it won't be.[/QUOTE]


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.DialgaBrite2014-02-03 19:13:08
B
15
S
2
Posts: 103
Reputation: 1,178

Post » Mon Feb 03, 2014 7:20 pm

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.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests