I would like to let my initializing script to create additional sensors/controller/actuators necessary for an interactive Blender application (not necessarily a game). This is preferable for two reasons:
Actually creating a template file partially addresses the first issue. But then I can't mix and match different parts for different projects, or I have to create a template for each possibility.
I have searched both the Game Engine docs and the Python API but couldn't find any clue. __init__
methods of logic bricks aren't even listed there.
But if there is any way to create logic bricks dynamically within Python I would like to try it.
NOTE: with my limited knowledge of BGE, you can't, for instance, access key presses directly from Python. A sensor is required.
I know this is a really old post, but the information is outdated. It is now possible to add actuators and sensors with python: http://www.blender.org/documentation/blender_python_api_2_60_6/bpy.ops.logic.html
In case anyone else is looking for the info.
So -- as it is, there is no way to create the logic bricks straight from Python.
When you instantiate an object in ther BGE (like with an add object actuator), the logic bricks from the instantiated object comes with it - and you can change and rearrange those - including the rewiring of the sensors, controler and actuators
I think this is the current workaround: you create a blank matrix of generic senor, controlers and actuators, and as you add new objects into a scene, call a function that fill-in the parameters for the logic blocks and do the required wiring.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With