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