Resource valleys python help

I used peasant.findNearestItem() in other levels and didn’t get the error messasge.

# Collect all the coins!
def findNearestItemInArray(array, peasant):
    item = peasant.findNearestItem() #<---E---R---R---O---R--- peasant has no method findNearestItem.
    for i in range(len(array)):
        for singlArray in array:
            if singleArray == array[i]:
                torf =True
                pos = singleArray.pos
                return torf, pos
            elif singleArray != array and i == len(array):
                for i in range(len(array)):
                    for singlArray in array: 
                torf = False
                return torf

def commandPeasant(peasant, coins):
    # Find the nearest coin to the `peasant` from the `coins` array,
    trof  = findNearestItemInArray(peasant, coins)
    if trof == True:
        pos = findNearestItemInArray(peasant, coins)
        # Command the peasant "move" to the nearest coin.
        hero.command(peasant, "move", pos)

friends = hero.findFriends()

peasants = {
    "Aurum": friends[0],
    "Argentum": friends[1],
    "Cuprum": friends[2]

while True:
    items = hero.findItems()
    goldCoins = []
    silverCoins = []
    bronzeCoins = []
    for item in items:
        if item.value == 3:
        # Put bronze and silver coins in their approriate array:
        if item.value == 2:
        if item.value == 1:
    commandPeasant(peasants.Aurum, goldCoins)
    commandPeasant(peasants.Argentum, silverCoins)
    commandPeasant(peasants.Cuprum, bronzeCoins)

Never mind I figured it out.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.