Error: End expected (to close if at 3:5) at 13:1 on the agrippa defence


#1
loop
    local enemy = self:findNearestEnemy()
    if enemy then
        local distance = self:distanceTo(enemy)
        if distance < 5 then
            if self:isReady("cleave") then
            self:cleave(enemy)
        else
            self:shield()
            self:shield()
        end
        end

this is my code it in lua and it not working


#2

please post your code according to the FAQ, it makes it easier to read your code


#3

As Devin has already said, read the FAQ prior to posting again.

Your ends aren’t quite right. The first one’s okay, the second one needs to be shifted back on level, and you need a third one to end the loop.