hello guys!
pls i need help with that lvl i have tryed for weeks and i dont know what 2 do
// This shows how to define a function called cleaveWhenClose
// The function defines a parameter called target
function cleaveWhenClose(target) {
if(hero.distanceTo(target) < 5) {
// Put your attack code here
// If cleave is ready, then cleave target
if (enemy) {
var ready = hero.isReady(“cleave”);
hero.cleave(enemy);
}
// else, just attack target
!
else {
hero.attack(enemy);
}
}
}
// This code is not part of the function.
while(true) {
var enemy = hero.findNearestEnemy();
if(enemy) {
// Note that inside cleaveWhenClose, we refer to the enemy
as target
.
cleaveWhenClose(enemy);
}
}
thats my code
please format you code properly, all you have to do is paste your code in between 6 backticks 3 on top, 3 on bottom, or you could just press this button and paste code there:
but from what i can see, you didn’t check if hero is ready to cleave, all you did was define a variable, which is useless on its own,
try adding another ‘if’ statement.
Please learn to post your code properly. It’s really easy and only requires a very small amount of effort.
To post your code from the game, use the </> button or it won’t format properly. When you click the </> button, the following will appear:
Please paste ALL of your code inside the triple back tick marks.
``` <— Triple back tick marks.
Paste ALL of your code in here.
``` <— Triple back tick marks.
There are many people here willing and able to help. If you use the </> button correctly, then ALL of your code should look like this:
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
else:
hero.say("My code is formatted properly")
If ALL of your code isn’t formatted like the code above, then you’re doing it wrong and we can’t see the structure of the code to troubleshoot whether or not that is the issue. Use the </> button and help us help you. This works when sending a private message as well.
Thank you.