Yo, guys If you are new, and you struggle with code!

Make sure your define a new variable when you are trying to communicate to a new wizard.
Instead of erz = las / 4, try something like

sim = erz / 4
hero.say(sim)

Do the same for Agata and define a new variable, aga
Make sure to use * for multiplication. If you need anymore help, reply to this post. Otherwise, this should be a good enough hint

It did not really work, the answer should be 3.25 and i tried to see if my hero could say it, and get it right but it did not work.

thx i tried some thing else and it worked thx

im stuck on blind distance

Show me your code and the problem you have in a NEW TOPIC

Tell the wizard the distance to the coming ogres.

This function finds the nearest enemy and returns the distance to it.

If there is no enemy, the function returns 0.

def nearestEnemyDistance():
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:

    # Say the value of enemyDistance variable.

Please post your code in a different topic.

1 Like

ok will do that right a way

i did it it is all ready to use

I donā€™t see your code anywhere.

ok i will send it to you

Tell the wizard the distance to the coming ogres.

This function finds the nearest enemy and returns the distance to it.

If there is no enemy, the function returns 0.

def nearestEnemyDistance():
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:

    # Say the value of enemyDistance variable.

In a new topic?
Also be sure to format your code according to the FAQ. You can click on the</> button and paste your code in there, or surround it in triple backticks.
If you donā€™t know where to find the FAQ, you can search FAQ in the search box and it should appear. :slight_smile:

type or paste code here
```# Tell the wizard the distance to the coming ogres.

# This function finds the nearest enemy and returns the distance to it.
# If there is no enemy, the function returns 0.
def nearestEnemyDistance():
    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: 
    hero.say(enemyDistance)
        # Say the value of enemyDistance variable.
    hero.say(enemyDistance)[quote="RenziYT, post:1, topic:10045, full:true"]
Ask me questions about your level here, up to Backwoods forest.:older_man:
[/quote]

> type or paste code here

As I said many times before, please open a new topic for this.

On the Home page: discourse.codecombat.com

You see near the top of the page it has tab bars with the words Latest, New, Unread, Top, and Categories right? The New Topic button is on the right and has a + sign next to it. Click on the button and fill out the information accordingly. Running around and posting your code everywhere will not help and brings up old topics.

Hi, could you please help me have a look that why my code is wrong? I was trying to define the inAttackRange.

Thanks a lot in advance for your assistance and look forward to your reply!

Whenever the error message says that it ā€œgot nullā€ it means that, at the moment when it checked for distance, there was no enemy. Try checking for the existence of an enemy before checking for distance to an enemy. This can be done two ways, either by a separate if statement before the one on line 9 or using ā€œandā€ together with the existing if statement on line 9.

1 Like

Thanks a lot for your detailed explanation, very much appreciate it. :slight_smile:

Hi,

Iā€™ve got a generator

generator = game.spawnXY(ā€œgeneratorā€, x, y)
generator.spawnType = ā€œskeletonā€

My question is how can I assign a health number to each skeleton (not the generator itself)?