# Sarven Shepherd Bug w/ Lua & Python

**URL:** <https://discourse.codecombat.com/t/sarven-shepherd-bug-w-lua-python/10460>\
**Category:** Bugs\
**Created:** [February 6, 2017, 1:30pm UTC](https://discourse.codecombat.com/t/sarven-shepherd-bug-w-lua-python/10460 "2017-02-06T13:30:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CLND](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/clnd/32/5799_2.png) [@CLND](https://discourse.codecombat.com/u/CLND)\
**Post date:** [February 6, 2017, 1:30pm UTC](https://discourse.codecombat.com/t/sarven-shepherd-bug-w-lua-python/10460/1 "2017-02-06T13:30:04Z")

</div>

So when I was playing this level I did everything correctly except when ran, the hero just stopped in the center. I have done everything asked in the level. But all my hero does is instead of detecting the enemys that are attacking him, he just repeatetly goes to (40, 32). I wondered if this was a bug with Lua because most levels are in JS or Python when I boot them up. So I opened the level in Python and had the exact same experience.

Here is the Lua code I used:

```python
-- Use while loops to pick out the ogre

while true do
    local enemies = self:findEnemies()
    local enemyIndex = 1

    -- Wrap this logic in a while loop to attack all enemies.
    while true do
        local enemy = enemies[enemyIndex]
        -- "~=" 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
                hero:attack(enemy)
            end
        end
        
    -- Between waves, move back to the center.
    hero:moveXY(40, 32)
    end
end

```

---

<div class="post-metadata">

**Author:** ![Gurrman](https://avatars.discourse-cdn.com/v4/letter/g/bcef8e/32.png) [@Gurrman](https://discourse.codecombat.com/u/Gurrman)\
**Post date:** [February 6, 2017, 3:47pm UTC](https://discourse.codecombat.com/t/sarven-shepherd-bug-w-lua-python/10460/2 "2017-02-06T15:47:27Z")

</div>

What level name is it?

---

<div class="post-metadata">

**Author:** ![CLND](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/clnd/32/5799_2.png) [@CLND](https://discourse.codecombat.com/u/CLND)\
**Post date:** [February 9, 2017, 5:14pm UTC](https://discourse.codecombat.com/t/sarven-shepherd-bug-w-lua-python/10460/3 "2017-02-09T17:14:19Z")

</div>

The name of the level is in the title of the post.
