Why doesn't this work?

I use the code
enemies = self.findEnemies()
if enemies:
self.attack(enemies)
but it says that it doesn’t work. may I have some help???

You are targeting multiple targets when you can only target one. You have to do it with a single enemy.

okay but why do the current glasses I have only target everyone when I want to target one?

What glasses do you have?

The Kithgard Workers Glasses

Then define enemy as self.findNearest(enemies) after doing enemies = self.findEnemies(). After that all you have to do is replace enemies with enemy in this: if enemies: and self.attack(enemies)

2 Likes

@Neel_Sharma Thanks for the help!

1 Like

No problem slamdunx.

1 Like

Sorry for the extra question but how do I turn enemies into enemy exactly?

didn’t i say that in post 6?
Another thing, I can’t post correct code.

HERE IS A LINK!:

DA LINK

Does code type matter?

are you saying that instead of [quote=“Neel_Sharma, post:6, topic:7123”]
if enemies:
[/quote]

and[quote=“Neel_Sharma, post:6, topic:7123”]
self.attack(enemies)
[/quote]

I put enemy in those parentheses? Because if so the game says that enemy isn’t defined.

I’m sorry @Neel_Sharma This is something that is taking me some time to understand

Have you played the level Lurkers? It explains how to use findEnemies(). You can also use the documentation found in the spell pallete for findEnemies() for more examples.

In short:

  • findEnemies() returns an array/list of enemies.
  • attack(enemy) takes a single enemy argument.
  • You cannot attack() an array/list.

So you choose an enemy from the list of enemies. There are multiple different ways of choosing an enemy:

enemies = self.findEnemies()
nearestEnemy = self.findNearest(enemies) # choose nearest enemy with `self.findNearest()`
firstEnemy = enemies[0] # choose first enemy in list
# Make sure your enemy isn't null/None, then do whatever with it.
1 Like

@trotod I actually haven’t played Lukers yet, I am currently on medical attention. thanks for the help though.

do self.attack(enemy);