BACK-TO-BACK level lua


#1

On level ‘Back to back’ in forest I get ReferenceError: enemy is not defined when my code looks like:

while true do
    enemy = hero:findNearestEnemy()
    if enemy then
        hero:attack(enemy)
        hero:attack(enemy)
    else
        hero:moveXY(40, 34)
    end
end

#2

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)


#3

@szymex73

It should be:

local enemy = hero:findNearestEnemy()