I got stuck on blind distance

while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    var (distance = hero.distanceto(enemy):
        if (distance.isready("cleave"):
            hero.cleave(enemy)
        # Say the value of enemyDistance variable.

Hi! This part looks like a salad mixed with different conditions and abilities.

Comment ‘’‘# If the enemyDistance is greater than 0: ‘’’ says about zero and there is nothing about it in code line.
I’ll chek the level and try to show the scheme)

1 Like
while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    
        # Say the value of enemyDistance variable.
        

I don’t know what to do

Uhm. You don’t need to cleave. Follow the level instructions:
#It’s an ambush and your only weapon is the old, blind wizard.
#Your task is to tell him the distance to the coming ogres.
#Don’t worry about the direction.
#The wizard’s powers are limited, use them only when see an ogre.
#This function finds the nearest enemy and returns the distance to it.
#If there is not enemy, the function returns 0.
#Call ‘nearestEnemyDistance’ function and save a result in a variable ‘distance’.
#If ‘distance’ is greater than 0:
#Say the distance.

So the scheme is smth like this:

def nearestEnemyDistance ():
    [code is precoded so you even dont need to write it] 

while True:
    define enemy
    define distance-to-enemy
    if distance-to-enemy>0:
        say distance-to-enemy

The wizard will hear the distance-to-enemy and finish all the job for you)

My solution differs a little bit, but it’s OK.

In fact you need to write two lines of code: condition and say distance.

while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    
    if distance-to-enemy>0:
        
        # Say the value of enemyDistance variable.
        distance = hero.distanceTo(enemy)
        

Looks like you don’t understand basics and only copypaste pieces of code of other players( It won’t let you learn much about coding. Maybe it’s a good idea to step back to previous levels to understand mechanics of operators and conditions.

2 Likes

Thanks for noooot helping!!

1 Like

You’re welcome) Always glad to)

2 Likes

I’m really sorry I could disappoint you. But.
I recommended you the most effective and easiest way. Not the fastest, but really working one. Of course you can try other variants. Like get solution from another person, or get subscription and prompt of game stuff, or any else you can imagine).
I don’t know much about programming, but I have been training/teaching young guys for about 15 years and I know a thing or two about learning. If you want to know something - you need to do it by yourself.
One more really fast, but hard way to beat this lvl I can give is to try find connections between things in goals, given code and advices of this level.
As I mentioned only two lines of code should be done. Cmon, look at it as at interesting rebus, puzzle. Not a work or compulsory deadline.
Good luck!

2 Likes

Let’s keep it civil please. Alex is actually trying to help, but not by just giving you code.

2 Likes

You know what I am sorry. I got mad but I been doing this code for at least 2 day.

1 Like
    enemy = hero.findNearestEnemy()
    result = 0
    if enemy:
        result = hero.distanceTo(enemy)
    return result

while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    distance = hero.distanceTo(target)
        # Say the value of enemyDistance variable.
    hero.say(distance)

1 Like
while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    distance = hero.distanceTo(target):
        # Say the value of enemyDistance variable.
        hero.say(target)

1 Like

Suddenly you get closer)
Ok, let’s pretend we need as little work with this lvl as we can.
You have hints and you successfully did the first step - you made variable

enemyDistance = nearestEnemyDistance()

Don’t touch anything else now)
Look at comments

#If the enemyDistance is greater than 0:
#Say the value of enemyDistance variable.

So, turn comment line [If the enemyDistance is greater than 0:] into code with right spelling and operator. Hint - it should be one line of condition code.

2 Likes

As soon as you will be ready to the next step, you’ll need to use variable you created.
I’d explain it like this: if you got pet, you give it the name. And when you want to call pet, you say its name. The same thing here. You create variable and then your hero should say this variable.

1 Like

Well @Lydia_Song has been stuck on Restless Dead for 2 months, I’ve been helping her out but she still hasn’t got it yet, but don’t worry you will eventually get past it.

1 Like

And also Welcome to the Discourse @kayden4444 :partying_face: :partying_face:

Can I see your recent code @kayden4444?

Oh, and I have not been too much active on the forum lately because I have been in a holiday in the mountains for some weeks and I did not had really good signal there, but now I am back!

Andrei

1 Like

while True:
    # Call nearestEnemyDistance() and
    # save the result in the variable enemyDistance.
    enemyDistance = nearestEnemyDistance()
    # If the enemyDistance is greater than 0: 
    distance = hero.distanceTo(target):
        # Say the value of enemyDistance variable.
        hero.say(target)

@AnSeDra

1 Like

Where did you check if the distance is greater than 0?

1 Like