Links between BGE Logic Bricks
Open, NormalPublic

Description

Currently, the Python API exposes properties, sensors, controllers and actuators of any object's logic brick graph and their methods and props. However, the links between the bricks (i.e. what controllers are linked to a given sensor or what controllers are linked to a given actuator) are not exposed. Without this information, its difficult to export information about the logic brick graph from Python (say, to use the logic brick graph information in third party game engines, as is done for eg. in the open source 'Gamekit' framework).

This patch exposes the aforesaid links from the DNA structs bSensor and bController using the RNA API.

Some code snippets illustrating the use of this patch:

>>>list(bpy.data.objects[1].game.sensors[0].linked_controllers) #Lists the controllers attached to specified sensor
>>>bpy.data.objects[1].game.sensors[0].linked_controllers[0] #Returns the first controller attached to sensor
>>> bpy.data.objects[1].game.controllers[0].linked_actuators #Returns collection of actuators linked to given controller
>>> bpy.data.objects[1].game.controllers[0].linked_actuators[0] #Returns first actuator linked to current controller

Pending issues:
While bController stores an array of pointers to bSensors ('slinks'), this array doesn't seem to get updated. Consequently, >>>bpy.data.objects[1].controllers[0].linked_sensors
always returns an empty collection.

Details

Type
Patch