I have objects that get created all the time. all the duplicates have the same name “y line draw”. they all have the same boolean property “active”. I need a way of deleting all the duplicates that have their property “active” set as “True” if a given event occurs. here is what I’ve tried:
a = 0
for i in scene.objects:
if i == "y line draw":
a += 1 #pretend this part deletes the objects
print (a)
a = 0
obj = scene.objects["y line draw"]
for obj in scene.objects:
a += 1
print (a) #pretend this part deletes the objects
I know of a way I could do it in the logic editor, but I like to do as much as possible inside the code.
from bge.logic import getCurrentScene
...
def endObjectsWithPropertySet(objectName, propertyName):
for object in getCurrentScene().objects:
if (object.name == objectName and
object.get(propertyName)):
object.endObject()