[SOLVED] Keeping Time Help Needed


#1

Using this code, my hero just stands there and not do anything. What is wrong with this?

# Use your new skill to choose what to do: hero.time

while True:
    # If it's the first 10 seconds, attack.
    if hero.time < 10:
        if enemy:
            enemy = hero.findNearestEnemy
            hero.attack(enemy)
            pass
    # Else, if it's the first 35 seconds, collect coins.
    elif hero.time < 35:
        if coin:
            coin = hero.findNearestItem
            hero.moveXY(coin.pos.x, coin.pos.y)
        pass
    # After 35 seconds, attack again!
    else:
        hero.attack(enemy)
        pass

#2

add () to the end of the 6th line of code and in the 12th line of code.


#3

I tried it, same results.


#4
  1. You have a conditional statement, if enemy, before you define the variable, enemy.
  2. You have a conditional statement, if coin, before you define the variable, coin.

You must define your variables first before using/calling them.


#5

I mean like coin = hero.findNearestItem()


#6

Also, check if the enemy exists after 35 seconds.


#7

This worked. Thanks.