node object geting list of properties with python

i am working on an rts game i need the ai bots to get the list of the objects with a propertie

Try this:


###
gl.List=[]

for i in range(0,len(List)):
    obj = List[i]
    
    if hasattr(obj,"property to look for"):
            
        if own.getDistanceTo(obj) < 500: # Max Distance
            gl.List.append((obj.name))

    gl.List #List of objects
    print gl.List

And if you want to find the nearest object add this at the bottom:

lt = len(gl.enemyList)
    enemyRanges = []
            
    if lt > 0:                        
        for i in range(0,len(gl.enemyList)):
            enemy = List[gl.enemyList[i]]
            dist = own.getDistanceTo(enemy)
            enemyRanges.append((dist,enemy.name))
    
        enemyRanges.sort()
        own['target'] = OB' + enemyRanges[0][1][2:]

And lastly, a link to my A* pathfinding demo - http://blenderartists.org/forum/showthread.php?t=174092

thank you so much dude :slight_smile: