Help: Medical Attention

Indent this

Should be an elif

Lydia

1 Like

This should be turned into

This

if currentHealth < healingThreshold:
        
        hero.moveXY(65, 46)
        hero.say("heal me")
1 Like


while True:
    enemy = hero.findNearestEnemy()
    currentHealth = hero.health
    
    
    
    
    elif currentHealth < healingThreshold:
        
        hero.moveXY(65, 46)
        hero.say("heal me")
       
    if enemy:
        hero.attack(enemy)
    
1 Like

Did it work now(20 char)

1 Like

no elif or an elif does it need to be an if or an elif

1 Like

This should be an if

This should be an elif

1 Like

so you now have this

    elif currentHealth < healingThreshold:
        
        hero.moveXY(65, 46)
        hero.say("heal me")
       
    elif enemy:
        hero.attack(enemy)
1 Like

it no work and the duck is saying healingThreshold is not defined



while True:
    enemy = hero.findNearestEnemy()
    currentHealth = hero.health
    
    
    
    
    if currentHealth < healingThreshold:
        
        hero.moveXY(65, 46)
        hero.say("heal me")
       
    if enemy:
        hero.attack(enemy)
    
1 Like

replace this

with this

    enemy = hero.findNearestEnemy()
    currentHealth = hero.health
    healingThreshold = hero.maxHealth / 2
1 Like

it worked thanks guys

1 Like

You need to define healingThreshold like this:
healingThreshold = hero.maxHealth / 2

1 Like

Now mark whichever post helped you solve this problem

1 Like

i already did that man

1 Like

You didn’t so just mark this

As solved

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.