Save and Load script v4.3

I always tought that world was better to use then local. And i alwys wonder what causes that issue haha, i gonne change the world into local and re-upload it.

Using local space shifts the dependency from the order of parenting to the assumption that the parenting chain is intact. If it is not, then thatā€™s a problem in itself, so itā€™s a worthwhile assumption to make.

THANK you verry much, I love this

Some reason when i press L once put into my game, anything with spawned boolean gets removed, and i can`t see it on the map ?

How do you mean? every object that needs to be saved needs a property ā€˜saveā€™ - boolean - True or false.
Every scene that gets saved needs to have an empty (or object) called ā€˜spawnerā€™.

if you load the game with L and everything getting removed, this means you used the save property for inactive objects, be sure that objects in the main layer got the property save - boolean - false.
and every object from an inactive layer needs to have save - boolean - True.

Oh ok my bad. I was putting spawner on my character witch deletes it upon load ?
I got some questions, i have a weapon and it goes weird when i press load, i have to press
it a couple times to make it go back together and place back in the hand, any way around that ?

Also how can i make it permanent save ? is it possible ?

do you have a save property on youre weapon?
also saving is kinda permanent, everything gets saved to globaldict, so once you have saved you can just load the globaldict upon the start of the game engine.

I did, but does that just save the property of ammo ? or location of weapon ?
Sorry for so many questions, it`s a brilliant script and want too implement it into my game.

Sometimes when i press L, it does not load, i`m trying to setup a save box of some kinda
where i can click save game or load.

  1. yes it saves all. i cant get past that pont, already changed world to local in the hope it would fix it.
    But to bypass that you could just write a litle script for the weapon so it copies the orientation of the empty or bone its parent to.

  2. look at the menu from my blend. you see what ive done there to save it, just convert it to any action you like.

  3. hmm did you check the console output for why it dont load?
    i have no problems here with loading or saving, just did some tests.

Originally Posted by theoldguy http://blenderartists.org/design/baorg2012dark/images/buttons/viewpost-right.png
Thank you for this script. It works very well. Now with a functioning save/load maybe Iā€™ll move from 2.49 to 2.73. http://blenderartists.org/forum/images/smilies/sago/smile.gif

One thing I did notice. If you have a Text property parented to the camera in the main scene, (like Socials FPS, Ammo, Mags, Text) it saves the location of the planes itā€™s mapped to. LOL Then when saved, ends up off the camera. LOL Iā€™ll play with the code later to see if I can stop it from saving objects positions, and save only Text properties.

Thanks again.

Thanks Agoose, didnā€™t see your post till just now. :slight_smile:

Actually the best way is to have the Text properties on a HUD scene, and always overlay the HUD scene. Which is what I did with Socials FPS. (Mags, Ammo, etc) Problem solved. :slight_smile:

If the Text property absolutely must be on the main scene (for whatever reason)
I think the Text property should copy the property from an empty. The empty would have the ā€œsaveā€ on it. :slight_smile: (un-tested)

Thanks Agoose and Cotax. This is very handy indeed.

Is there anyway to re-name the BGECONFIG in game? Like rename level1.BGECONFIG, to level2.BGECONFIG when the player reaches a checkpoint. That way when using blend files as levels, when you finish level1.blend, and use the ā€œstart game from fileā€ actuator to go to level2.blend. It will load the (now re-named) level2.BGECONFIG file? Is that even possible? Would that work?

Is there anyway to re-name the BGECONFIG in game? Like rename level1.BGECONFIG, to level2.BGECONFIG when the player reaches a checkpoint. That way when using blend files as levels, when you finish level1.blend, and use the ā€œstart game from fileā€ actuator to go to level2.blend. It will load the (now re-named) level2.BGECONFIG file? Is that even possible? Would that work?

To be honest i have not looked into this, so i have no idea. I know you can change the directory with python etc, or save the gd to a txt file who you can modify. but to be honest with this save and load you dont need it, due to it save all scenes in the GD, just make sure that you dont use duplicated scene names and you can load it trough the scene name, instead of the blend file.

scene_to_load = GD['save game'][scene.name]

Hmmm, I try that. Being able to carry data from blend to blend would allow a person to create a large game that could play on weaker PCs without a drop in frame rate. By keeping the blend files small. Games with as many levels as ā€œFar Cry 3ā€ including the side missions. (Opens up a larger market)
Using scenes as levels, or linked libraries, will quickly get too large to play on weaker machines. And Libload libfree is broken. :frowning: Anyway I fear I might be getting off topic.

Great job with the save load script, I use it in every game I make.
If I ever sell a game (Ha, not likely anyone would pay for my crappy games) Iā€™ll kick you in for a percentage. :slight_smile:

Libload is not broken, for me it works perfectly fine, and you use Python to store data then, which is better than saving into a file (in most cases).

Then this script uses globalDict, which is a bad idea generally speaking. Since people here doesnā€™t care as long as it works and its easy to use nobody complains, but itā€™s not for the lack of reasons. In the first place it saves in the same directory than the game folder, this has been an outdated practice since about 10 years ago, nowadays the game folder is usually protected against writing making this script pretty much useless. And secondly the extension name, ā€œbgeconfigā€, seriously? Which part of a save file is a configuration file? Not only globalDict is designed badly, but also itā€™s not even designed for this purpose.

I know you all donā€™t care, but from my point of view the use of globalDict in this script is an epic fail.

Libload is not broken. . .

It works for me also, as long as I donā€™t try to do too much with it. But others here have said not to use it, because it wonā€™t work or is unstable on others PCs.

As far as the save/load. It works for what I want perfectly. And thats more than I can say for a lot things. But I respect your opinion. :slight_smile:

In the first place it saves in the same directory than the game folder, this has been an outdated practice since about 10 years ago, nowadays the game folder is usually protected against writing making this script pretty much useless. And secondly the extension name, ā€œbgeconfigā€, seriously? Which part of a save file is a configuration file?

indeed, saving to the same directory may cause a problem. a Save game is a config file, no matter how you look at it. it saves the config(uration) of all saved objects thus making it a config file, we call it a save file (arent we stoopid to do that?).

But with that said. I have upgraded the save and load to Version 3.0.
It will now use the GD to collect all data and then saving the GD to a file with the name and location of choice.

problem solved, have fun with version 3.0.

Good work, now it looks a lot better for me (though I use my own scripts).

About the configuration fileā€¦ well no, a configuration file and a save file are different things. The configuration file saves global configurations of the game (Sound volume, Graphic details, Language, etcā€¦) a save file saves the state of the game the last time the player left it (object positions, experience, points, etcā€¦). Its not a good practice to mix them, you donā€™t want to open an old saved game and find out that you have to reconfigurate everything because at that time you had a different graphic card or whatever.

Edit: Or worse, download a save file of a completed game from the internet and find that now all the characters speak Chinese. Also a configuration file should be used before launching the game to launch it with the appropriate flags on the graphic details and so one, most of the time when the game tries to low the resolution because it was too hight it has already crashed.

Also, notice that now it works horribly wrong by default on linux systems, it creates a ā€œC:ā€ directory in your home folder, but in any case thatā€™s more related to the paths than the saving itself so I assume itā€™s out of the scope of this project. :wink:

This works great for one save. Is there any way to save more than one time at different levels in the game? And to name each one differently so you can pick from a list of which you would like to load? Then this would be the perfect solution for all of us gamers. Also where is the file location the global dictionary is stored in? I canā€™t see anything in the same same folder that I put demo game in.

you can acces scene data from the savefile and use it when needed.
GD[ā€˜save gameā€™][ā€˜scene nameā€™]

did you read the script?
location + name is located at the top of the script

v2 save GD at blend location
V3 save at location of choice (default c:/my game/saves/save.sav (i thought)) (on linux it will create a c: folder in your home folder as elmeunick9 said.

Atm i got no time to alter it so your on your own, but if i can create some time, then i will look into your request.

* New version * (24-01-2018)
4.0 changes some things that just got in the way for some people.

- Individual save files, yes thatā€™s right every scene getā€™s itā€™s own save file now.
- Changed the save property, Oh yeah, you donā€™t need to mess with the Boolean anymore, just add a property called save to the objects you want to save, and the scripts handles everything.

nice work, i hope you get enough time to work on your key bindings and make it impossible to use the same key for more than one function, something like:

if there is a key used for more than one function we canā€™t save the change and a message appears saying repeated key error.

or if we use the same key the old function will change to no key. for example:
if forward key is W, if we press W for backward the forward key change to no key.