-- Use while loops to pick out the ogre loop local enemies = self:findEnemies() local enemyIndex = 1 -- Wrap this logic in a while loop to attack all enemies. while enemyIndex < #enemies do local enemy = enemies[enemyIndex] --use index numbers to select enemy local enemyIndex = enemyIndex + 1 -- "!=" means "not equal to." if enemy.type ~= "sand-yak" then -- While the enemy's health is greater than 0, attack it! while enemy.health > 0 do self:attack(enemy) end end end end -- Between waves, move back to the center.
So this is my code in Lua for https://codecombat.com/play/level/sarven-shepherd,
It’s working, without any errors, but character idles for few seconds on killing an enemy. I have no idea what causes the problem.
Also, I don’t know how to make my character “back to center” between waves, I know self:move(x,y), I just don’t know when is the “between waves” thingy.