Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Yak rampage not working

My dude wont collect the gold or go to the exit. here is my code:

def attack(target):
    if target  and target.type!='sand-yak':
        if (hero.distanceTo(target) > 10):
             
            if (hero.isReady("bash")):
                hero.bash(target)
            if (hero.canCast('chain-lightning', target)):
                hero.cast('chain-lightning', target)
        else:
            hero.attack(target)
            hero.shield()
#step 1
hero.moveXY(120,39)
while hero.time<100:
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type!='sand-yak':
        attack(enemy)
    else:
        hero.move({'x':120, 'y':39})
#step 2
while True:
    enemy = hero.findNearestEnemy()
    item = hero.findNearestItem()
    if item:
        hero.move(item.pos)
    elif enemy:
        attack(enemy)
    else:
        hero.move({:60, 'y':35})

sorry wrong code lemee get it

# You've disturbed the yak's nest, and they're furious!
# Survive for 60 seconds by kiting and dodging the angered yaks.
hero.findFlag("green")
if flag:
    hero.pickUpFlag(flag)

try putting the hero.find flag inside of the while true loop

You have to put all of that inside a while-true loop.
Lydia

The rubber ducky is saying that flag is not define.

That’s because you didn’t define flag

then how should make it define?

You should have learned this a long time ago . . .
Ex
object = hero.findFlag("green")
Lydia

you do this flag = hero.findFlag(“green”)

Don’t literally type object

Why? It would still work. . .

no she or he would have to type if object

Do you have to do this level to keep goin on the quest?

??? It would work. And as I said, it was just an example.
Lydia

Never mind let’s just drop it

no you do not have to play this level to move on in the campaign

:scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream: :scream:

didja all already do this level?