Volcano Fighters HELP

When i run my code it says


here is my code:

# Complete the paladin rectangle to protect the village.

paladins = hero.findByType("paladin")



# This function finds the left-most unit.
def findMostLeft(units):
    if len(units) == 0:
        return None
    mostLeft = units[0]
    for unit in units:
        if unit.pos.x < mostLeft.pos.x:
            mostLeft = unit
    return mostLeft

# This function finds the bottom-most unit:
def findMostBottom(units):
    if len(units) == 0:
        return None
    mostBottom = units[0]
    for unit in units:
        if unit.pos.y < mostBottom.pos.y:
            mostBottom = unit
    return mostBottom



# Find the top left paladin with findMostLeft function:
def findTopLeft(units):
    if len(units) == 0:
        return None
    mostTop = units[0]
    units = findMostLeft(units) 
    for unit in units:
        if unit.pos.y > mostTop.pos.y:
            mostTop = unit
    topLeft = mostTop
    return topLeft
    
    
# Find the bottom right paladin with findMostBottom function:
def findBottomRight(units):
    if len(units) == 0:
        return None
    mostRight = units[0]
    findMostBottom(units)
    for unit in units:
        if unit.pos.x > mostRight.pos.x:
            mostRight = unit
    bottomRight = mostRight
    return bottomRight

# Use X coordinate from the top left paladin:
# and Y coordinate from the bottom right paladin:
if paladins:
    coordX = findTopLeft(paladins).pos.x
    coordY = findBottomRight(paladins).pos.y
# Move to the {X, Y} point from the previous step:
hero.moveXY(coordX, coordY)
# Continue to shield while the volcano is erupting:
while true:
    hero.shield()

@AnSeDra
:smiley: :smiley: :smiley: :smiley: :smiley:

On what line do you get the error?

Andrei

Doesn’t say :face_with_raised_eyebrow:

1 Like

Try to delete this.

Andrei

Could it be this? I haven’t tested it, but while true should have a capital T.
Danny

1 Like

And I wanted to mention that too.

Andrei

I know I have fixed that

1 Like

Nope I still says there is no object

1 Like

Gtg sorry. Bye!

Andrei

Can you show us your new code?

Andrei

Try to delete the findTopLeft and findBottomRight functions and take the x coordonate of the mostLeftUnit and the y coordonate of the mostButtomUnit.

Andrei

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