Leave it to cleaver again

ok so i know i said that i fixed it but now he wont attack after he cleaves

# This shows how to define a function called cleaveWhenClose
# The function defines a parameter called `target`
def cleaveWhenClose(target):
    if hero.distanceTo(target) < 5:
        pass
        # Put your attack code here
        # If cleave is ready, then cleave target
        hero.isReady
        hero.cleave(target)
        # else, just attack `target`!
        hero.attack(target)

# This code is not part of the function.
while True:
    target = hero.findNearestEnemy()
    if target:
        # Note that inside cleaveWhenClose, we refer to the `enemy` as `target`.
        cleaveWhenClose(target)

nvm i figured out that i needed to do

else:

ok so now that is out in the else he just sits up at the top and wont do anything for the rest of the time

def cleaveWhenClose(target):
    if hero.distanceTo(target) < 5:
        pass
        # Put your attack code here
        # If cleave is ready, then cleave target
        hero.isReady
        hero.cleave(target)
    else:
        hero.attack(target)

# This code is not part of the function.
while True:
    enemy = hero.findNearestEnemy()
    if :
        # Note that inside cleaveWhenClose, we refer to the `enemy` as `target`.
        hero.isReady("cleave")
        cleaveWhenClose(enemy)
    else:
        hero.attack(enemy)

Hi again) Don’t want to be mean or rude, so, don’t take my words close to your heart. Just pay attention to the things I mention.

  • The strangest part of the code.

Whar is this “target”? I dont see this variable definition.

Another one pretty unusual construction. It’s better to place operator if and condition in one line of code.

Also your while true loop almost duplicate cleaveWhenClose(enemy) function.

I don’t think you really wanted to put pass there.