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

Goalkeeper confusion


For some reason, my peasants are walking towards me instead of the ball. This is my code:

# Command the peasants to prevent the ogres from scoring.
# The fireball is type "ball".
    friends = self.findFriends()
    for peasant in friends:
        self.command(peasant, "move", {"x":15,"y":ball.y})


findByType always returns a list. You want the first (and only) item in that list, which is at index 0:

    ball = self.findByType("ball")[0]


I think i got lucky
i just pressed submit and the ogres failed to make 1 goal