Munchkin Swarm help!

loop
    -- Check the distance to the nearest enemy.
    local enemy = self:findNearestEnemy()
    -- If it comes closer than 10 meters, cleave it!
if enemy then
    local distance = self:distanceTo(enemy)
    if distance < 10 then
        if self:isReady("cleave") then
            self:cleave(enemy)
    -- Else, attack the "Chest" by name.
     else
            self:attack("Chest")
end
    end
        end
end

My character keeps waiting after he cleaves to attack the chest. How do I make keep attacking the chest in the beginning and when the enemy comes, he murders them all. After he cleaves, he start attacking again. I am using Lua btw.

Not sure, but the is the indentation of the else statement correct? It seems off by one space. I got no experience with Lua though… so this may not work