save game scene is it possible ?

I am facing the problem with saving my game scene
to be more precise, i can click on multiple buttons to add tons of buildings clones and it needs to be saved

I am very curious if blender engine is loading usual .blend from inside the .exe file so it could be ?possible? to save edited in-game scene again to rewrite the executable .
Can someone explain process of loading finished scene to the game ?

Since there is no scene file in the game folder, i assume it is compiled with blender engine into single exe file (now i am losing my hope :slight_smile:

No, this is not possible.

Blender creates .blend files.

The BGE uses .blend files as input to extract certain game data from it. It does not write .blend files. I think this is the reason why it is called Blenderplayer ;).

Finally this “feature” has no use in a game. What you need is a save/load system (check the resource sub-forum). Store the games current state in a persistent or semi-persistent storage. Restore it at a later time. While doing that you need some logic that modifies the existing scene in a way that it has the structure described in your storage.

E.g. you save “I have: Cube at 3,0,0 Sphere at 0,0,1, Cylinder at 1,2,3”
On restore you kick everything out except Cube, Sphere, Cylinder and place Cube at 3,0,0, Sphere at 0,0,1, Cylinder at 1,2,3
You do not have a Cube as active object? Create a copy form the Cube at the inactive objects via addObject().

You do not have Cube as active or inactive object? Then you scene is not able to restore this save state.

Btw. The Blender engine does not “compile” anything. All it does it binds the blenderplayer with a .blend file. [This is a different step than compiling - but still part of a build]. There is no need to do that. You can run any .blend file with the blender player.


blenderplayer [--options] filename.blend

what if I have Cube1 cloned many times with addObject command every clone has the same name ‘Cube1’
I wanna save positions of all clones

what if I have Cube1 cloned many times with addObject command every clone has the same name ‘Cube1’
I wanna save positions of all clones

you can write a save and load script, so you can save when the game is running and loading aswell, and once saved you can… after a restart, load all data fromt the save file.

for this you need to use python and globalDict
look at resource forum or at monsters/my signature.

Yes - cotax’s method is very great for saving spawned objects and all objects at all;)

Thank you soooo much cotax
God bless you :slight_smile:

This does not matter. If you know they are all copies of the same file you can addObject a new object for with each saved object state.

Look at my signature. follow the resources link. It contains a saveLoader that demonstrate exactly that. I do not know if the latest Blenderversion produce some problems. But you can try it with earlier versions.

I did realize that after hours of thinking :stuck_out_tongue:
nice links now I see how powerful blender is