Save and Load script v4.3

And if they want it they can grab it from here, if they don’t want to use the forum not my problem

1 Like

in Cotaks defense, the code is probably is alot more meanful in context with a blend file setup.

2 Likes

Ok, I got it. Thanks!

1 Like

I was wondering if you could make the save-load script save different parts of the game. As an example a cube could have a property called “save2” and a sphere can have the property “save”. If you load save 2 then only the cube would load, but if you load save then only the cube would load.

that behavior is far too specific for a template.

just make a list of the properties to look for and create a new file accordingly.

i dont know exactly how this works, but it should be easy to do this.

I would not create such thing in a save and load script. It becomes a custom script. What you could do is just save it all, and keep track with a list what objects you don’t want to keep. Then when loading is done, simply call a function that removes the objects that you have stored in the list.

Hi guys
I loved your system! :heart: @Cotaks

much better than mine done a few years ago…

I saw that there were still a few more options
he doesn’t save parent.

here is the modification, controlled in real time:
save_and_load 4.4.blend (618.0 KB)
instructions are in the file

Do you mind if I use it on my projects?

2 Likes

It does not because: if you spawn an object that has something parented to it, it will spawn that object as well, thus keeping the chain intact. If you end something with a child that child will be ended as well.

You only want to save the parent if you are already adding it in runtime.

No, go ahead.

2 Likes

well now it’s already possible, it’s another option.
there are some more improvements that I will try to make

Thanks!

1 Like

I loved your script, but I’m having some problems with changing the scene. How do I change the scene, load all the properties saved in the previous scene to the current object and scene?

you need to write in English, otherwise hardly any here is going to understand what your writing.

1 Like

This script is not made to carry data from 1 scene to an other scene.

This is a game saver, meaning at the point you save it will save everything into files per scene. So basically… if the scenes are the same you can just load in the ‘other_scene.save’, but for this you need to disect the load part of the script so it only loads one file and the file you need the data from.

The very optimal setup for this script would be:

  • 1 main.blend
  • a folder with you levels.blend

then using libload you can load in your level.blend into you main.blend, then if you save it it will keep all data intact for the current setup. when switching levels use libfree to remove the loaded objects (from level.blend) and load in a new level.blend (save an object with a property with the blend loaded, so you can libload that blend before loading the save file or let the script handle it if you just spawn objects in and got them in your main.blend as well).

Doing it like that would give you the option to:

Have 1 main blend where your game is played in

  • this will hold every over- and underlay scenes, can also keep the player in there
  • this in turn will make sure that all the data you have on the player or in your hud stays useable throughout the game without saving.

Eliminating the need to transfer data from 1 level to another and you can make a nice loading screen for it as well.

#edit:
If you need to transfer data from one to another scene, then you need to make your own script to save that data into the globalDict() and load the globalDict in your new scene and then grab the data out of it to be used.

1 Like

this doesn’t seem to work on 0.30.0 upbge? i pressed all keys on my keyboard and it does nothing but create boxes and change the cylinder color.no saving no loading.

No, this does not work in Upbge 0.3.0, only made for BGE based/build on v2.79 up to Upbge 0.2.5.

oh man! is there a way you can make it compatible with upbge 0.3.0?

No, not for now sorry. Upbge 0.3.0 isn’t ready to make games with, the whole structure is different, it’s just not worth it to spend time on it to convert it to 0.3.0.

i take it back.it DOES work on upbge 0.3.0. but it doesn’t save the scene were you left the game,neither on upbge nor blender GE 2.79. on blender 2.79 i added another scene(level_2)full copy of level_1. when i save and load, it loads an old save not the new added scene(where i saved).it even freezes the game.am i doing something wrong?

My guess is that you open your game without scene 2 active and then try to load, that does not work, it does not activate scenes, so you should open your game have that scene 2 open then press load.

If you want multiple levels then you also need to look into libload and use 1 main blend where you load in the levels and save the data of that blend into a property and load from it at start, or simply use multiple blends, if level 1 is done you can open level2.blend with logic bricks, but here the same thing apply you need to also store the data on wich level you are or wich blend to load. These can be added into the save, as a simple property, but you need to build the mechanic yourself on how to process that property data.

for example:

  • property called level: default value level 1

when you get to level 2 change the value to level_2 or something

now either use bricks or python to handle that property and load in the correct scene, and this should run before you load the game, so that the savefile can actually load the needed stuff.

yes.i was thinking about that.but wasn’t sure how to do it exactly.thank you