while(true) {
var enemy = hero.findNearestEnemy();
} if (hero.isReady("cleave")) {
hero.cleave(enemy);
} else {
hero.attack(enemy);
}
Not sure home to fix this
while(true) {
var enemy = hero.findNearestEnemy();
} if (hero.isReady("cleave")) {
hero.cleave(enemy);
} else {
hero.attack(enemy);
}
Not sure home to fix this
Welcome to the forum @Logan_Hofer!!
Can you please tell us the level and post your code correctly as it says in this?
Lydia
@Logan_Hofer Welcom to the forum!
Please try to format your code correctly like Lydia_Song said.
I think that the issue with your code is that you don’t check to see if there is an enemy. It should look like this:
if enemy:
Hope this helps!
Grzmot
while(true) {
var enemy = hero.findNearestEnemy();
} if (hero.isReady("cleave")) {
hero.cleave(enemy);
} else {
hero.attack(enemy);
}
No code will run after a while (true)
loop unless it is broken, take this as an advice.
~ Orb
Proper formatting not withstanding, why are you closing your ‘while true’ before any other code runs?