Why doesn't this work?


#1

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???


#2

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


#3

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


#4

What glasses do you have?


#5

The Kithgard Workers Glasses


#6

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)


#7

@Neel_Sharma Thanks for the help!


#8

No problem slamdunx.


#9

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


#10

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

HERE IS A LINK!:

DA LINK


#11

Does code type matter?


#12

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.


#13

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


#14

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.

#15

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


#16

do self.attack(enemy);