# Need help Eagle Eye level - Lua

**URL:** <https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650>\
**Category:** Uncategorized\
**Created:** [August 14, 2016, 5:57pm UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650 "2016-08-14T17:57:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![NentoR](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@NentoR](https://discourse.codecombat.com/u/NentoR)\
**Post date:** [August 14, 2016, 5:57pm UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/1 "2016-08-14T17:57:07Z")

</div>

Need help with this level. Using Lua Language.

---

<div class="post-metadata">

**Author:** ![GAIGAL](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gaigal/32/4412_2.png) [@GAIGAL](https://discourse.codecombat.com/u/GAIGAL)\
**Post date:** [August 14, 2016, 9:48pm UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/2 "2016-08-14T21:48:03Z")

</div>

Hi! Whats problem? This level dont so complicated…

---

<div class="post-metadata">

**Author:** ![NentoR](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@NentoR](https://discourse.codecombat.com/u/NentoR)\
**Post date:** [August 15, 2016, 6:28am UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/3 "2016-08-15T06:28:22Z")

</div>

Tried all but cant win this level. How i can tell my hero to attack only Ogres ? I tried but i cant

---

<div class="post-metadata">

**Author:** ![NentoR](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@NentoR](https://discourse.codecombat.com/u/NentoR)\
**Post date:** [August 15, 2016, 6:14pm UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/4 "2016-08-15T18:14:56Z")

</div>

Someone help ? Pleaseeee ?

---

<div class="post-metadata">

**Author:** ![Alexbrand](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Alexbrand](https://discourse.codecombat.com/u/Alexbrand)\
**Post date:** [August 16, 2016, 7:25am UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/5 "2016-08-16T07:25:12Z")

</div>

Umh, I think you’re OK, it’s broken)  
A couple of days before I helped my son with this level and he passed it. But now the same code on my computer doesn’t work. I’ll look a little bit closer later, now gotta go.

Heh, level is OK (Python), I was wrong - forgot to take sword)

Post your code, formatted properly, and maybe you’ll get some hints.

---

<div class="post-metadata">

**Author:** ![NentoR](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@NentoR](https://discourse.codecombat.com/u/NentoR)\
**Post date:** [August 16, 2016, 8:55am UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/6 "2016-08-16T08:55:41Z")

</div>

I think this level is bugged. Can’t attack Ogres.

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [August 16, 2016, 11:55am UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/7 "2016-08-16T11:55:03Z")

</div>

Could you give more information? The error which you get at least, screenshots, your code. It’s hard to help you if we don’t see your problem.

---

<div class="post-metadata">

**Author:** ![NentoR](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@NentoR](https://discourse.codecombat.com/u/NentoR)\
**Post date:** [August 16, 2016, 12:09pm UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/8 "2016-08-16T12:09:01Z")

</div>

[![](http://i.imgur.com/7qnF4oa.jpg) ](http://i.imgur.com/7qnF4oa.jpg)

Other example:  
[![](http://i.imgur.com/HN6C2nL.jpg) ](http://i.imgur.com/HN6C2nL.jpg)

Both didnt working.

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [August 16, 2016, 1:10pm UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/9 "2016-08-16T13:10:00Z")

</div>

The level isn’t buggy. Please try to read comments and guides more careful.  
I’m not sure what you are trying to do here: `local doAttack = ("ogre")`

Use `shouldAttack(target)` and assign the result to the variable `doAttack`. Then check it with `if-statement` and attack `target` if it’s so.

---

<div class="post-metadata">

**Author:** ![NentoR](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@NentoR](https://discourse.codecombat.com/u/NentoR)\
**Post date:** [August 16, 2016, 5:07pm UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/10 "2016-08-16T17:07:23Z")

</div>

Can’t understand this level. Please someone give me all code.

---

<div class="post-metadata">

**Author:** ![UltCombo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ultcombo/32/3822_2.png) [@UltCombo](https://discourse.codecombat.com/u/UltCombo)\
**Post date:** [August 17, 2016, 4:42am UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/11 "2016-08-17T04:42:59Z")

</div>

We don’t give full solutions as a forum policy. This is because the concepts you are supposed to learn in this level will be necessary in future levels, so if you don’t understand it properly you will likely get stuck again soon and it will be harder to help you then.

Bryukh did a pretty good job describing what you have to do, but I’ll write it in a different way so you can have another go at it.

This level is supposed to teach you how Boolean values work (a Boolean is a value that can be `true` or `false`), and to use them inside a condition.

The `shouldAttack` function returns a Boolean (true or false) indicating whether you should attack the target or not. So what you have to do is to store the result of this function inside a variable:

```python
local doAttack = hero:shouldAttack(target)

```

Here, you are passing the nearest enemy to the `shouldAttack` function and it will return whether you should attack it or not, then this result is stored in the `doAttack` variable.

At this point, the `doAttack` variable contains a value that is either `true` or `false`. Now you can do a conditional check (`if doAttack then`) to only perform an action when `doAttack` is `true`. This part is already correct in your code. Inside the conditional block, you are supposed to `attack` the target—I believe you should know how to do this by now. 🙂

* * *

In the future, please be specific with what you didn’t understand, so that we may be able to help you. Human communication is the most important programmer skill! 😉

---

<div class="post-metadata">

**Author:** ![NentoR](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@NentoR](https://discourse.codecombat.com/u/NentoR)\
**Post date:** [August 17, 2016, 6:13am UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/12 "2016-08-17T06:13:29Z")

</div>

Done 🙂 i needed only this. Thanks to UltCombo

---

<div class="post-metadata">

**Author:** ![monk](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@monk](https://discourse.codecombat.com/u/monk)\
**Post date:** [September 10, 2016, 12:37am UTC](https://discourse.codecombat.com/t/need-help-eagle-eye-level-lua/8650/14 "2016-09-10T00:37:41Z")

</div>

thanks a lot , I unlocked this level thanks to your response. I did not understand very well the speech , I hope to better understand later .
