Editor Helper | Select Objects With Game Property

Version

UPBGE 0.3

Script:

A small helper script that’s works with BPY to select objects with a stated game-property if it possess it.

import bpy

PROP_NAME = "Health"

for obj in bpy.context.scene.objects:
    obj.select_set(False)
    for prop in bpy.data.objects[obj.name].game.properties:
        if prop.name == PROP_NAME:
            print(bpy.data.objects[obj.name].game.properties[0].name)
            bpy.data.objects[obj.name].select_set(True)
            bpy.context.view_layer.objects.active = obj