#Need Help with SSave again

1 messages · Page 1 of 1 (latest)

wintry token
#

Ok so since the last time I was here begging for guidance. I learned how to use structs since I couldnt use ds maps to hold my save information for ssave. I have a basic understanding of structs as in a know how to set up the save file with it, how to load the data out. how to create one, add data to it and check references to it.

So i finally started looking at SSave and I have no idea what does what. Both youtube videos fly by it super fast and don't explain what you actually need from it to do anything or assume that you are using that save system as a whole. I already have a system for save slots (i just spent 2 hours figuring it out and making it work properly) I just want to add encryption to my save files and possibly that feature about syncing old saves with new data.

All the comments are one liners that dont really explain what the function does and the code isnt commented so i can understand the gist of what its doing. The demo is basically uncommented I cant even find where in the demo it even calls the save or load functions its supposed to be showing you how to use. If anyone could shed some light on this and make it more understandable, it would be greatly appreciated.

maiden sphinx
#

Have you seen this video I made about SSave? https://youtu.be/WP44Y7wzyx8?si=ZSGu4Q73examoAfg

There's a huge number of great guides for saving and loading data in GameMaker but a newly released free package for GameMaker has made it incredibly easy to create save files which can be encoded or encrypted with one line of code.
SSave by stoozey is an open-source project available on itch.io and GitHub and promises to tackles some common pro...

▶ Play video
#

If you haven't or have any questions, I'll do my best to answer 🙂

wintry token
#

Hello and yes, this was the first video I saw but you go over everthing so quick that I don't understand what the scripts actually do. I had to watch the video numerous times before I saw where you were actually assigning the variables to be saved.

Like at 1:15, is that where you are assigning the variables and values to be saved? Because it looks like you are doing that at 1:40 where I thought it was showing you load the save data so it could be displayed.

Is the example in the video actually loading anything from the save file or are you just assigning strings and values to the array?

is the [saves[0].load("0");] what loads all the save data? how does it know what value to put at what variable?

It says on itch.io "Old saves automatically sync with any new data you add to your project that wasn't originally in the save file.
You can be 100% sure that a value in your save file is ALWAYS there, even if removed from the file" Where is this done and how do I use this feature?

I'm assuming as far as save slots and showing the loaded info, its just as simple as using .get("info")? Where does it show the different commands in the script so I can know what I can use since they just seem like variables cause the text is blue.

Does it automatically decrypt the savedata to load or do i have to do that somewhere in the load script?

Do i have to scrap the save system I was using previously to use this one? (the scripts aren't commented in a way that explains what happening)

Most of my issue is that the script isnt commented clearly and there is no documentation on how things work and how to implement it. The demo from itch.io doesnt event tell you where to you're supposed to put the data you want to save. Sorry for the wall of text but this has been making my head hurt for a while.

maiden sphinx
#

Hi, sorry you didn't understand everything - I did go through everything quite quickly

#

I'll try and help out but I'm guessing we're in different timezones so might be a bit tricky

#

At 1:15 I'm defining the format of my save file. As I mention in the video, SSave requires that you tell it what kind of data (i.e. string, number, array, boolean) you will be saving. So at that point in the video I'm telling SSave that it should expect to receive a value called name which will be a string etc. So yes, at 1:40 I am setting the actual values there

maiden sphinx
#

The example is loading things with the .load("0") bit at 1:40. But I can see why you would be confused as the code immediately overwrites whatever was saved with the .set("name, "player 0") stuff. In an actual game, you would move the 'set' code to wherever you want to update the save data. Then you would put the 'save' code from around 2:05 to the game end event or something

#

In the function 'add_value' at 1:15, the third argument ("", 0, [ ], and false) represents the default value. So when you call the 'load' function, it loads those default values at first.

#

It's been a while since I used SSave tbh but for you question about 'Old saves automatically sync with any new data...' I believe that this is done automatically. What it is referring to is that if you change the format of your save data (for example, a new version of your game introduces a new variable to be saved) then loading an old save file won't crash the game but the new variable will be silently added with the default value.

#

Yes, 'get' will retrieve the data from the save. You can see most of the functions you may need in the scr_ssave file which is included in the package.

#

It will automatically decrypt the save data for you.

#

You probably will have to scrap the save system you were previously using but I would weigh up the pros and cons. SSave has some cool features but it might be worth sticking with a save system that you understand better. It's up to you.

#

Please let me know if I can help more.

wintry token
#

Ok so just making sure I understand what you mean. I declare the variables and give them their default value in the ssave construct. Im assuming this is what it uses to patch the save files if there are new variables that arent in them. At another part I use the .set(); to actually assign the values to the variables created. After that the struct stringify and write to the file happens. And then when it comes to loading, I use the .get(); to display the information and then to actually load the save file its just the load command shown at 1:40?

wintry token
#

the save system i have is extremly basic. its literally just a struct with global variables that gets stringified and json saved to file with the buffer stuff. So when i was looking through the scripts, thats what i was looking for and couldnt see it.

#

I've never used someone elses scripts as is before without doing it step by step and learning how it works. that why i was so lost when nothing was commented clearly

wintry token
#

Ok, I got as far as setting up SaveFile() : SSave("save") constructor. Since I'm not overwriting a save slot, what do i address with .set(); ?

maiden sphinx
#

These are the four basic steps:
Line 1 - create a new variable which will be an empty save file as defined in the SaveFile constructor function
Line 2 - try and load the save file called "0" (if the save file doesn't exist, it proceeds with the blank save file fine)
Line 3 - update the save file
Line 4 - save the file (either overwriting the file called "0" if it exists or creating a new one)

#

What might be confusing you is that the variable 'session_save' isn't actually a direct reference to the save file, rather its just a temporary way of storing what was saved previously. Then, it's this temporary save data which gets updated and finally saved down to the actual save file on your computer.

#

If you are still stuck, I'd highly recommend going line by line through the demo on GitHub https://github.com/stoozey/SSave. It doesn't have comments which I understand can make it difficult to learn from but if the coding concepts used are too advanced for you then you might want to use a simpler system. Personally, I think this video demonstrates a good save system as well if you're looking for an alternative: https://www.youtube.com/watch?v=R84mR52QaMg&t=741s

Like the other tutorial I did, only better. A universal approach for when you need to save or load data in GameMaker, using JSON, structs and arrays.

▶ Source code: https://www.patreon.com/posts/44109513
▶ Support my work: https://www.patreon.com/shaunjs
▶ This same tutorial for older versions of GameMaker: https://www.youtube.com/watch?v=QmxQb...

▶ Play video
wintry token
#

The system I started with was ShawnSpaudlings. I then made changes for it to use structs instead of arrays. The only issue I have with it is that the savefile is human readable and can be edited to break the game. That was why i was looking for something that could encrypt it so it couldn't be tampered with.

#

I will try working with those 4 lines you gave me and see if I can understand how to make this work. Thank you for your help

wintry token
#

Ok, I was able to make some headway and isolate where the encryption and decryption happens and was able to successfully encrypt a save file and decrypt it to load the file. Would you happen to know if there is a way to compare structs to see if they have the same indexes?

maiden sphinx
#

Could you explain what you mean be 'same indexes'?