Airdrop again (Python)

Hi,

I’ve got a problem with that one, too. I don’t understand the concept behind it. It says I should protect the left side. Fine. There’s the red cross where I stand and fight. My raven doesn’t search for anything, cause according to the code I should search for it but if I start the giant ogre will kill the villagers. And if I don’t I keep standing on the right cross and finally a horde of munchkins come from the other sides of the forest and kill my villagers. This is nuts.

This is my code:

# Get all swords and protect the village.

def onSpawn (event):
    while True:
        item = hero.findNearestItem()
        #  The pet should fetch the item if it exists:
    if item:
        pet.fetch(item)
    pass

# Assign onSpawn function for the pet's "spawn".
pet.on("spawn", onSpawn)

while True:
    # Guard the left passage: 
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
        pass
if item:
        pet.fetch(item)

will never execute …
Wrong indentation in while True loop.

1 Like

Just get better armor if your pet cannot lift them, use Okar Stompfoot.

1 Like

Ha, tiny little thing. I missed it, you’re right ^^

Now works just great. Thanks ;D