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

Can't read the property "Start" [SOLVED]

Hi,

Can semeone explain to me what is this “Start” property ? Thanks

while True:
    coin = hero.findNearestItem()
    enemy = hero.findNearestEnemy()
    friend = hero.findFriends()
    if coin:
        hero.move({"x":coin.pos.x,"y":coin.pos.y})
    cost = hero.costOf("soldier")
    distance = hero.distanceTo(enemy)
    if hero.gold > cost:
        hero.summon("soldier")
        for "soldier" in friend:
            if enemy:
                hero.command(friend, "attack", enemy)
            else:
                hero.command(friend, "move", {"x":hero.pos.x,"y":hero.pos.y})

and heres a image
Start

Which line is the prob on?

Also, try replacing soldier with friend in your for loop. You should also check on your for loop. In coding, some tiny mistakes can cause a problem; friend should be friends.

Is this Cloudrip Brawl? You have several errors and ducky is right about mismatch between friends and soldiers. Excerpts from your code:

while True:
# code
    friend = hero.findFriends() # this is an array of friends, name the variable friends
# code
# check if enemy exists before searching the distance to
    distance = hero.distanceTo(enemy)
    if hero.gold > cost:
        hero.summon("soldier")
# more logical is for friend in friends where friends is the array of friends
        for "soldier" in friend: # "soldier" is a string, must be friend or if you want soldier
            if enemy:
                hero.command(friend, "attack", enemy) # choose between soldier or friend
            else:
                hero.command(friend, "move", {"x":hero.pos.x,"y":hero.pos.y}) # same as above

Hi,

WOW ! that was quick x) and thanks for ducky and xython for your help seriously !

and how to close the topic ?

Just edit the title to say, [SOLVED].