Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Self.findenemies() returns a door object!


in Cavern Survival i am running this code:

    enemies = self.findEnemies()
    enemy = self.findNearest(enemies)
    if enemy:
        if self.isReady("cleave"):

However the hero attacks a door! It would appear that the self.findenemies() function thinks door are enemies. Is this intended behaviour?



I think so, as you can attack them. You should be able to avoid them using their names or types.

1 Like

It is intended. you can attack them, they are an enemy they even have a team assigned to them

1 Like

How can I find out the door’s name or type then? I tried:
(hero.say is sort of intend for use as print function?), but it only returns an incomplete gibberish (i.e. if the door’s name or type is mentioned in the output, the game is snipping it/not showing it.


As for Cavern Survival’s doors, the type is “door” and names are “West Door” and “East Door”.

With clicking on them) Names and type shown in the bottom of the level.


Did you mean hero.findNearestEnemy() instead of hero.find.NearestEnemy()?

1 Like

Actually, yes - thanks for the tip.


So to address the elephant in the room: How to exclude that darned door from the attack?


Well, using enemy.type and operators and and != in def killEmAll() function may be a good idea?

1 Like

not sure if this will work, and it will probably not, but use

enemy = hero.findNearestEnemy()
enemy = enemy + enemy.type != "door"

I think you can’t add strings


You could just do something like

enemy = hero.findNearestEnemy()
if enemy:
    if enemy.type != "door":

Yeah, but then the hero will sit around there doing nothing, until another enemy comes.


I think it may depend on the glasses the hero uses?


It only attacks nearest enemy: it will not act until door isn’t nearest. enemy.