Set Game logic through Python?

Example: I create new object with python for example some Lamp is it possible to add Game logic for new created object?

Better example would be

I want to create simple level editor in xml file.
If in python reads something like this

<door> pos=“0,2,3”>doorBig</door>

python would create scene with empty or some other object on position 0,2,3 and add some game logic to that object. Is that possible or i need all my stuffs do in Blender.

Sorry for if you find it confusing :o

You cannot use Python to add Logic Bricks while the game is running.

Also, are you thinking of using the main Blender module to add objects to the scene while the game is running? I don’t think you can do that. Others have tried this in the past and had no success. If I understand correctly, it does not work because you cannot call Blender.Refresh() while the game is running. Blender holds all Refresh() calls until the game ends, so the new objects would not show up in the scene until after the player exits the game.

You can make level editors and map loaders that read from text files, but you must do it by adding predefined objects with the Edit Object Actuator.

Thank you! It would be very nice that we can add that in blender. I’m not using BGE long maybe 2-3 days but from now what i seen its looks very powerful and easy to use. I never use Python but when i look in some codes i understand it very good because i have some expiriens whit OPP languages like java and JavaScript. And i used blender a lot for in other game teams i worked.

Hmm… one more question for example if i have more then one palm tree in my level how BGE see them when i duplicate them in Blender and start game. Is it all those models in memory or only one and others are duplicated. Or i need to make one and then duplicate them with game logic in BGE? So that is know that is not allocating all stuffs in memory if there are same.

Thank you for support!

Kristo,

actually it’s possible to access, create and modify logic bricks in Blender. I have created plug-in to access these data. There is thread on this plug-in and the most actual version is included in ODYS Blender plug-in (it’s used to export game data).
Plug-in is not complete (supports only few types of sensors and actuators - Keyboard, Mouse sensor; Motion, Action actuator), but if you will need other types, I can add them.

Ashsid that looks very nice i will try it tnx!