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

Sarven Treasure 1 help please

I can’t get 150 i always get 149 not 150

while True:
flag = hero.findFlag()
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
if flag:
pass # pass is a placeholder, it has no effect.
# Pick up the flag.
hero.pickUpFlag(flag)
else:
# Automatically move to the nearest item you see.
item = hero.findNearestItem()
if item:
position = item.pos
x = position.x
y = position.y
hero.moveXY(x, y)

1 Like

Hi @anon66968315! Could you post your code as it is explaned here?
[Essentials] How To Post/Format Your Code Correctly?

1 Like

hello @anon66968315. i have a good value over distance recipe which might help you with this stage:

while True:
    gold = 3
    silver = 2
    bronze = 1
    coin = hero.findNearestItem()
    bestValue = gold * 10 or silver * 10 or bronze * 10
    # if you want to make sure that enemies don't kill you, put an if statment like this:
    enemy = hero.findNearestEnemy()
    # if enemy:
        # hero.attack(enemy)
        # you can also have a few abilities in here.
    if hero.distanceTo(coin) < bestValue:
        hero.moveXY(coin.pos.x, coin.pos.y)
        # or if you have better boots: hero.move(coin.pos)
1 Like

it worker for me with 20 seconds to spare. there were a few monsters popping up but if you have good enough armour you can just ignore them