Need help Eagle Eye level - Lua

Need help with this level. Using Lua Language.

Hi! Whats problem? This level dont so complicated…

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

Someone help ? Pleaseeee ?

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.

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

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.

Other example:

Both didnt working.

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.

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

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:

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. :slight_smile:


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! :wink:

1 Like

Done :slight_smile: i needed only this. Thanks to UltCombo

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 .