Help with convenient enemy


#1

why wont this work?

# Ogres are hiding in woods. Protect the peasants.
# The last word in the peasants' messages are a hint.

for x in range(8, 73, 16):
    hero.moveXY(x, 22)
    # Peasants know whom to summon.
    peasant = hero.findNearest(hero.findFriends())
    message = peasant.message
    if message:
        # Words are seaparated by whitespaces.
        words = message.split(" ")
        # "words" is an array of words from the "message".
        # Get the last word. It's the required unit type.

for i in range(len(hero.built)):
    unit = hero.built[i]
    # Command the unit to defend the unit's position.
    hero.command(friend, "attack", target)
    nearest = hero.findNearestByType("potion")
    enemies = hero.findNearest(hero.findEnemies())
    
    # Defend the last point yourself:
    if enemy:
        at
    


#2

sorry i mean

# Ogres are hiding in woods. Protect the peasants.
# The last word in the peasants' messages are a hint.
for x in range(8, 73, 16):
    hero.moveXY(x, 22)
    # Peasants know whom to summon.
    peasant = hero.findNearest(hero.findFriends())
    message = peasant.message
    if message:
        # Words are seaparated by whitespaces.
        words = message.split(" ")
        # "words" is an array of words from the "message".
        # Get the last word. It's the required unit type.
for i in range(len(hero.built)):
    unit = hero.built[i]
    # Command the unit to defend the unit's position.
    hero.command(friend, "attack", target)
    nearest = hero.findNearestByType("potion")
    enemies = hero.findNearest(hero.findEnemies())
    
    # Defend the last point yourself:
    if enemy:
        hero.command(friend, "attack", target)

#3

also what is the rock paper scissors reference suppose to mean


#4

and finally why dose it keep telling me to add 4 spaces on the blank spot at the end because when i do that it adds another blank space at the bottom where it tells me to put 4 more spaces there


#5

wait this is actually my code

# Ogres are hiding in woods. Protect the peasants.
# The last word in the peasants' messages are a hint.
for x in range(8, 73, 16):
    hero.moveXY(x, 22)
    # Peasants know whom to summon.
    peasant = hero.findNearest(hero.findFriends())
    message = peasant.message
    if message:
        # Words are seaparated by whitespaces.
        words = message.split(" ")
        # "words" is an array of words from the "message".
        # Get the last word. It's the required unit type.
for i in range(len(hero.built)):
    unit = hero.built[i]
    hero.summon("soldier")
    # Command the unit to defend the unit's position.
    hero.command(friend, "attack", target)
    nearest = hero.findNearestByType("potion")
    enemies = hero.findNearest(hero.findEnemies())
    
    # Defend the last point yourself:
    if enemy:
        hero.attack(enemy)

#6

it wont let me summon the soldier


#7

try doing the hero.summon("soldier") #For me, it does work, or try hero.summon("archer"),Or just use a ranger if you are subscriber.