Share Logic script

Dalai just committed my patch to expose the links between logic bricks.

Last year i was working on a script that allow to export the logic system in a shareable file, but i stopped since i needed the informations my patch exposes.

Right now i have no time to continue developing it, but it almost finished.

Here the code of the script
http://pastebin.com/2hkTKbYL

Here the structure of the file
http://pastebin.com/XgEjBP2t

If someone has the time to finish it, i think it will be a big help to the community (right now sharing logic setups is rather difficult)

Nice stuff, but there’s a handful of comments in the beginning of the script (first 85 lines or so) that’s not in English… Would help reading the script if those lines where translated.

Makers_F as soon as i finish my addon, i’m more than happy to help :slight_smile:

So what will this patch allow you to do? Allow you to recreate logic bricks with Python (in Blender, not in the BGE)?

Basically, it will export all the attributes held by logic bricks on an object (i’m not sure about properties; haven’t read the code) to an XML file. This can then be read by the same script to exactly mirror the bricks on another object. It’s applications include tutorial support, help support and other features to share innovation. Yes, this is Blender as it uses bpy.

The Italian writings are just personal notes, what really matters is in English.
The script already can export properties, physic and all the game settings.
It will export even logic bricks connected between different objects.
In addition the file format is studied so that it won’t save the object name, so you just share logic set-ups, not real object.
The workflow i imagined is that you run the script, select the object from which the script should get the infos, label them with a symbolic name (eg “player”, “enemy”, etc…) and then save.
When you import the file with the script, it will make you choose the object to which should be copied the logic (using the previous symbolic name “player”, “enemy”, etc…). The script than checks if the type is the same (maybe we should allow to disable this check), eg light, object, armature, camera, and then copies all the saved stuff, keeping the relations between the “player”, “enemy”, etc…

Additional note:
the script is already developed so that if new blender revisions add new kind of properties or attributes, it will still save and load them without the need to update it (not sure if files generated with the old rev would be compatible with new ones.)