error with monster saveloader and mouselook

Hello! I tried to reproduce Minecraft building and deplacements systems with bge but i get an error with mouselook script when i reload (with Monster SaveLoader python script) saved objects. My mouselook freezes and i have this error in console:

KX_GameObject.GetPropertyNames() - Blender Game Engine data has been freed, cannot use this python variable

It seems that it is a problem when i try to load mouselook.py line 288, but i don’t understand what is wrong. "G"etPropertyNames instead of "g"etPropertyNames?

https://drive.google.com/file/d/0B3GouQIyoCmrTTB2VnpxVVFYMjQ/edit?usp=sharing

To test the game:

commands:

-up: R key
-down: F key
-left: D key
-right: G key

-Left clik to add a cube (when added the first, you have to look for it with the mouse because the camera isn’t well positioned)
-right clik to delete a cube.

-S to save
-L to load

Thank you very much for your help!

(i solved the problem using another mouselook script but i am curious to understand what is wrong with the .blend i’ve uploaded. Anyway, Thank you Monster for this amazing and very usefull script!)

Monster, i need your help!! hehe. It’s a good challenge for you! And an occasion to improve your saveloader. Precision: I’ve used saveloader.manual in my game…

Indeed it should be lower case “getPropertyNames”.

The error “Blender Game Engine data has been freed, cannot use this python variable” means the code is accessing a non-existing game object. This means the game object was ended (most likely in earlier in this frame) but the Python binding is still there.

Very interesting. Unfortunately I can’t look at this now. I will do this this afternoon.

… CU

Thanks for your answer:). I’ll try to understand what object is not correctly saved and why. When i save the game i get an Error converting type <class ‘main.Core’> but no more precision.

I had a look at your nice small file :). I just had a little problem to discover to do some thing. At least there was nothing to see when looking through the camera. With top view this is ok I can see it adds a cube on <1>.

The error message

Error converting type &lt;class '__main__.Core'&gt;

this is because you can’t save “non-serializable” property values such as references to game objects or in your case references to Python classes. This might look like a serious issue, but it is not. The referenced objects only exist at the time of storing. On restoring they will be gone and any data would be invalid. If really needed the references needs to be recreated (manually).

This is no big deal, tell the save loader to ignore this properties, or the complete game object. In your case this should be fine as it is the “mouse look”.

Add to the property saveLoad.excludeByProps to the object SaveLoad.manual with the value … “doNotStore” so the complete value is “saveLoad doNotSave”.
All objects with such a property will be ignored by saveLoad.

So add the property with name “doNotStore” to the Camera as this holds the “mouselook” which causes this above Error.

With this change the I can see the cube gets restored on load <L>.

Thank you very much! It works fine! And congratulations for your script. If you haven’t seen anything when pressing P to start the game, it is because you have to first add a cube with leftclik then find it with the mouse if it is not displayed on the screen. Then to add another cube you have to put the mouse over any face of the first cube and press left clik. Thank you again!