I am trying to figure out how to execute a line of code once there are no (alive) enemies on the map at the time. I do not know how to use null or nil yet. I did see another thread suggest trying enemies = null or something like that, but even with the best glasses in the game and making sure I properly defined “enemies”, I do not believe it worked.
I am practicing all the languages on offer, but I main LUA. Any advice appreciated, but please specify what language and anything specific to it if possible.
I will share just a snippet of my code below so we can see the general idea I’ve got going on. Feel free to work off this or offer something from scratch. All I’m looking for is the ability to tell the game to “do X when there are no enemies”.
Again, this is a pared down version of my code:
while true do
local enemy = hero:findNearestEnemy()
local enemies = hero:findEnemies()
if enemy then
if hero:isReady("bash") then
hero:bash(enemy)
hero:attack(enemy)
end
else if (enemies = nil) then
hero:moveXY(62, 65)
end
end
end