Copy sensors.
Here is some pretty untested code to copy sensors from active object to other selected objects.
import bpy
context = bpy.context
def copy_props(v1, v2):
''' copy props from v1 to v2 '''
props = v1.bl_rna.properties
for k, v in props.items():
if (k in ["rna_type", "type", "name"]
or v.is_readonly):
continue
setattr(v2, k, getattr(v1, k))
def copy_actuators(actuators, c):
ob = c.id_data
for a in actuators:
bpy.ops.logic.actuator_add(type=a.type,
name=a.name,
object=ob.name)
a2 = ob.game.actuators[-1]
a2.link(c)
copy_props(a, a2)
return c.actuators
def copy_controllers(controllers, s):
ob = s.id_data
for c in controllers:
bpy.ops.logic.controller_add(
type=c.type,
name=c.name,
object=ob.name)
c2 = ob.game.controllers[-1]
s.link(c2)
copy_actuators(c.actuators, c2)
copy_props(c, c2)
return s.controllers
# sensors
def copy_sensors(o1, o2):
''' copy sensors from ob1 to ob2'''
for s in o1.game.sensors:
bpy.ops.logic.sensor_add(type=s.type, name=s.name, object=o2.name)
s2 = o2.game.sensors[-1]
copy_controllers(s.controllers, s2)
copy_props(s, s2)
scene = context.scene
o1 = context.active_object
to_objects = [o for o in context.selected_objects
if o != o1]
for o2 in to_objects:
copy_sensors(o1, o2)
Result on your file.