if enemy then
local enemy = self:findNearestEnemy()
self:attack(enemy)
self:attack(enemy)
else
self:attack("Chest")
end
This is the code for Ogre Encampment. It wont work. the problem is that every time im delete a line whos empty, it wont go away. thats the error.btw its lua
Please format your code according to the FAQ. And also what programming language are you using? Looks to me like python. If so, you should not have local enemy. And also, you need a loop.
In python:
local enemy = self.findNearestEnemy()
self:attack(enemy)
self:attack(enemy)
else
self.attack("Chest")
Would turn into:
enemy = findNearestEnemy()
if enemy:
self.attack(enemy)
self.attack(enemy)
else:
self.attack("Chest")
As Luke says, Bashir, please read the FAQ and learn how to format your code properly. I’ve done it for your this time, but do so yourself in the future.
First of all, you should probably place this code in a loop, so that it will run over and over again. Second, you check for enemy, then define it. This is quite irregular. Move the definition of enemy before the if-statement.