Is there a better way to save?

Is there a better way to save this,

I thought about making the save section a function but itll still require me to go in and make a huge chain of set achievements (Redbox).

Basically. Im going to have about 30 achievements which means 30 of whats outlined in green.

I need to save them all which means pumping them through the save game line but with 30 sets integers in a row outlined in red.

Theres gotta be a better way, maybe enums or something. making an array?

Thank ye for your time.

Putting the save game code in a function makes perfect sense.

You can also have arrays of integers in the save game, if that helps.

Another handy thing you can do is, just manage the whole save game thing in the game instance. When the game starts make sure you have a good reference, and then just setup a timer to save every couple of seconds or so.

Then all you have to do is get a copy of the reference variable elsewhere. Update that, and you know it’s getting written to file with no hassle.

1 Like

Ok I can defo figure out how to shorten the save game into function.

The arrays in my head means I cut down on visible nodes in the graph but then will be updating the array insted. Potentially more work overall compared to just having 30 sets of achievements in fat row.

interseting. Ive dabbled in instances before But tbh Im still struggling around with saving and loading. Im going to reopen my investigations into instances and see where I go.

Im essentially just trying to figure out how to clamp down on repeating a blueprint 30 times and having a huge amount of visible nodes in sequence.

If you do it the GI way, all you have to do is update the variable :slight_smile:

In GI

Then, anywhere you want to use the save game

and you’re ready to go. Updating health, for instance

image

That’s it, because the GI deals with everything.

Also, if you use an interface to get the reference, you don’t even have that messy casting on begin play

3 Likes

Thank you so much, Ive stared at this for whats gotta be an hour lol. Ive done some tutorials etc but Ive gone into a confusing state reading up on the differences.
I can imagine its uses for ingame application but mines just for storing 1s and 0s.

Yes and nos for achievments, It saves when you gain an achievement but the more I add the more of a ratsnest it becomes.

Would game isntance organise this? Or would I have to do this for game instances as well as the hard save on quit.

1 Like

There problem you’re having there, is nothing to do with saving.

You’re missing a key blueprint concept. I think it’s probably arrays, but the code is very zoomed out.

So you can either have two arrays, one of names, and the other of integers, like this

Names

Values get filled in later

But then, getting it all from the SG is just

image

You can change them, and write them back

OR: you could do them as a map

Then you can lookup using the name

image

And write them

image

2 Likes

Hi, this subject caught my attention and a question came to my mind. As far as I can see in some places, they do archiving. What exactly is this needed for?

1 Like

Archiving? Do you mean saving?

That’s what this whole question is about.

When you play a game, and then you shut down your computer, and restart the next day. You expect the game to carry on from your last position, not to start from nothing.

That’s what this thread is about.

1 Like

No no. I guess I didn’t explain myself well.
Archiving while saving and loading. So serialization.

Where are you seeing that?! :slight_smile:

1 Like

I’m sure I’ve seen it in a few places. Maybe you’ll even remember when you see this.

			FMemoryWriter MemoryWriter(GameMode->SaveData.ByteData);
			FObjectAndNameAsStringProxyArchive Archive(MemoryWriter, true);
			Archive.ArIsSaveGame = true;

Right, but that’s not happening here.

1 Like

So if this isn’t about saving or loading, what is it about?

Primarily it is about saving and loading, but not serialization. Why bother to manually serialize the save game?

Also, it turns out it may be more about arrays, than anything else.

1 Like

As far as I know, data is lost during the save and load processes if some data is not serialized. Maybe it’s an old method about saving and loading.
I just wanted to ask a question about this, assuming you can help with this topic.
Thanks for your time.

The save game is serialized for you transparently, when using blueprint, you don’t have to worry about it.

No data is lost. I would be a bit of a crap system if it was :smiley:

If you’re using CPP, you might want more control over the way the serialization happens.

1 Like

I am using CPP, I write saving and loading codes without serialization.
It’s working as it should. However, a half-knowledge on this subject confused me.
In fact, I also did not get any efficiency or functionality when I implemented the demonstrations regarding serialization.

1 Like

Ive just managed to get some time to sit at my desk! Thank you for the detailed reponse, Im going to dive through it now.

Yeah this sounds correct in terms of my og issue. I just have this hive of infomation that feels terribly unefficient way of doing it.

Thank you again!

Edit. Ohhh I see about the zoomed out…ness, I tried to get some blown up pieces but its still blurry!
Ill see If i can reupload a clearer One.

editx2, Ok yeah Huge difference to saving and loading. This is going to be blurry but you can see the cut down on the huge bulk. Works beautifully.

So really the finale issue is cutting these 2 down.

The first is how it changes the array as you find the page number, They are one time events, and are upwards of 30 plus of them which is going to look insane by the end.

The other is calling the array individually to show achievments gained in the achievements page.
These two tbh I cant see a way to cut this down, It needs to all be done on an individual basis and thus I end up with 30 rows of one time events.

and again in the achivement screen another 30 calls to those achievements to show yes or no.

Im going to stare at it for a while and see If I can work it out.


The answer is the same. Arrays. You need and array of widgets. :slight_smile:

2 Likes