I’m not sure if I need to start a new thread or not…
I’m at wits end. The same code that regens Bernard is NOT working for Chandra. I checked the if
nesting and the second if
exp. is nested but Chandra is not getting her regen
.
How sensitive to correct spacing is the python ‘emulator’ to spacing?
Is this
hero.cast("regen","Chandra")
different from this?
hero.cast("regen", "Chandra")
Please advise.
NOTE: I was able to pass the level but Chandra never got her regen…
# Heal allied soldiers to survive the siege.
while True:
if hero.canCast("regen"):
#if expresssion 1
bernardDistance = hero.distanceTo("Bernard")
if bernardDistance < 10:
# Bernard needs regeneration!
hero.cast("regen", "Bernard")
# Use "if" and "distanceTo" to regenerate "Chandra"
# if she is closer than 10 meters away.
chandraDistance = hero.distanceTo("Chandra")
#if expression 2 must be nested
if chandraDistance < 10:
# Chandra needs regeneration!
hero.cast("regen","Chandra")
else:
enemy = hero.findNearestEnemy()
# If you aren't casting "regen", use "if" and "distanceTo"
# to attack enemies that are closer than hero.attackRange.
if enemy:
distance = hero.distanceTo(enemy)
if distance < 10:
hero.attack(enemy)
else:
hero.say("Come closer my pretty")