I’m trying to complete blind distance but i always run out of time because the wizard gets too tired too fast because he needlessly attacks when he doesn’t need too so i fail i have tried using stuff that isn’t involved in the level but no matter what it fails over and over its frustrating.
Can you please post your code?
Mod edit: [Please do not post working code]
Why would you command your hero to say("10")
? Surely you defined the variable enemyDistance for a reason. Maybe for you need to say enemyDistance (hint )
And of course now it works -_-
What did you change to make it work?
thx very much i solved it
been a great help
hope i enquire for more problems
I want to know as well.
I am stuck on this level:yum:
The 10 does not work for me why?
If you want help with your code, please could you post it on the discourse (formatted as it states in the FAQ) and say what you’re having trouble with. Thanks (also I don’t think @innerdesert4346 is active any more)
Thanks it worked and it is really helpfull
Hello I don’t mean to revive this topic , but I didn’t want to create a new topic since it already existed. At first I had code errors but I fixed everything and I don’t have the little duck alerting me.
The problem now is that my code has no errors and it “runs”, I say it “runs” because my character doesn’t do anything. I don’t know if it is a mistake I made or it’s a bug.
Please help! my code is below.
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:
if hero.distanceTo > 0 :
# Say the value of enemyDistance variable.
hero.say("nearestEnemyDistance()")
In your while True
loop, you’ve created a variable that you don’t use - enemyDistance
. Your if
statement should include this variable instead of the incomplete method that you currently have and this variable should be the argument in the hero.say
method.
so I should use enemyDistance
in my of statement?
@MunkeyShynes I guess not it gives the same result
Those two changes should have worked. Did you do both of the suggested changes? Please post your code again.
Because your hero is saying “nearestEnemyDistance()” or “enemyDistance”. These are the names of the function or of the variable and are strings, not actual value. These two hold the value of the distance.
a = 5
hero.say ( ‘a’) # output -> a
hero.say ( a ) # output -> 5
_TD_RodYT May '17
Why would you command your hero to say("10")
? Surely you defined the variable enemyDistance for a reason. Maybe for you need to say enemyDistance
enemyDistance = nearestEnemyDistance()
# If the enemyDistance is greater than 0:
if hero.distanceTo > 0 : # see above: this line is wrong
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:
if hero.distanceTo > 0 :
enemyDistance
# Say the value of enemyDistance variable.
hero.say("nearestEnemyDistance()")
first solution you suggested @MunkeyShynes
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:
if hero.distanceTo > 0 :
enemyDistance = nearestEnemyDistance()
# Say the value of enemyDistance variable.
hero.say("nearestEnemyDistance()")
second one.
maybe it doesn’t work because I misunderstood your explanation?
what? I don’t understand