# Ogres are scouting the forest!
# Use the distanceTo method to find where the enemies are.
# Say the distance for each enemy to tell the artillery where to fire!
enemy1 = "Gort"
distance1 = hero.distanceTo(enemy1)
hero.say(distance1)
enemy2 = "Smasher"
distance2 = hero.distanceTo(enemy2)
# Say the distance2 variable!
hero.say("distance2")
# Don't shoot at your friends!
friend3 = "Charles"
# The last ogre.
enemy4 = "Gorgnub"
# Find and say the distance to enemy4:
hero.say("distance4")
In the first one, you are defining a variable (the distance to Gort) and then saying it, so the result would be your hero saying a number, like 3. For the second one, your hero would say distance2.
enemy1 = "Gort"
distance1 = hero.distanceTo(enemy1)
hero.say(distance1)
enemy2 = "Smasher"
# Say the distance2 variable!
distance2 = hero.distanceTo(enemy2)
hero.say("distance2")
# Don't shoot at your friends!
friend3 = "Charles"
# The last ogre.
enemy4 = "Gorgnub"
# Find and say the distance to enemy4:
distance4 = hero.distanceTo(enemy4)
hero.say("distance4")
Look closely at that. What happens if you say distance1 is you say whatever is in the variable distance1, in this case, your distance to Gort. If you say “distance1”, what your hero says is “distance1”
enemy1 = "Gort"
distance1 = hero.distanceTo(enemy1)
hero.say("Gort")
enemy2 = "Smasher"
# Say the distance2 variable!
distance2 = hero.distanceTo(enemy2)
hero.say("Smasher")
# Don't shoot at your friends!
friend3 = "Charles"
# The last ogre.
enemy4 = "Gorgnub"
# Find and say the distance to enemy4:
distance4 = hero.distanceTo(enemy4)
hero.say("Gorgnub")
Read the comment. You’ve already found the distance and put it in the distance4 variable. Now all you have to do is say it. Using hero.say(), say the variable distance4 like
@Gabriel_Knight , you should be defining the enemy distance like you did. All you have to change is your hero.say Lines. Replace those with Hero.say (distance1), hero.say(distance2) and hero.say(distance4). If you put quotation marks the hero only says „distance1“, „distance2“ or „distance4“ and not the actual distance to the enemy.
enemy1 = "Gort"
distance1 = hero.distanceTo(enemy1)
hero.say(distance1)
enemy2 = "Smasher"
distance2 = hero.distanceTo(enemy2)
# Say the distance2 variable!
hero.say(distance2)
# Don't shoot at your friends!
friend3 = "Charles"
# The last ogre.
enemy4 = "Gorgnub"
# Find and say the distance to enemy4:
distance = hero.distanceTo(enemy4)
hero.say("distance4")