Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

[SOLVED]Plz help with sarven-siege


can’t get hero to build solider after collecting 20 coins, it would just collect up to 27 and stop
litte help would be very kind

def collectCoin():
    coins = hero.findItems()
    bestCoin = 0
    bestValue = 0
    for coin in coins:
        value = coin.value/hero.distanceTo(coin)
        if value > bestValue:
            bestValue = value
            bestCoin = coin
    if bestCoin:
        hero.moveXY(bestCoin.pos.x, bestCoin.pos.y)
while True:
    coin = hero.findNearestItem()
    gold =
    while gold <= 20:

while >= 20:
    if nearestTower:
        hero.moveXY(nearestTower.pos.x + 5, nearestTower.pos.y)


Instead of your

while > 20, 
if > 20


Because if questions it, while says that while it is at it, and it is not.


Thank you guys, I’ll try That asap :slight_smile:


solved it, thanks a lot :slight_smile:


Good job, you did it by yourslef!