Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Stuck on Power Peak. lev 46 Computer science 2

# Welcome to the Course 2 Arena. Defend against waves of ogres!
# Survive longer than your enemy to win!

#pet getting stuff

pet.on('spawn', petLogic)

def petLogic():
    # Add code to use your pet!
    # Move them to the power discs at the top of the map for powerups.
    pet.moveXY(54, 75)
    pet.say("Command me!")

#human getting stuff and then fighting
def humanLogic():
    while True:
        hero.moveXY(42, 47)
        hero.on('spawn', humanFighting)
        hero.moveXY(38, 31)
        hero.on('spawn', humanFighting)
        hero.moveXY(26, 23)
        hero.on('spawn', humanFighting)
        hero.moveXY(14, 31)
        hero.on('spawn', humanFighting)
        hero.moveXY(10, 47)
        hero.on('spawn', humanFighting)
#human fighting
def humanFighting():
    while True:
        # Improve your hero's default code!
        # Move to the nearby power discs to spawn units to help or attack!
        enemy = hero.findNearestEnemy()
        if enemy:

What im trying to do is split actions up into groups.
so the hero has a fighting script that is separate from the rest of it.
but the problem is, is that there is a error but the error box thing is bugged out and is stuck at the bottom of the screen so I was wondering if I could get some advice on what to do.

@CHARLES_CRAWFORD, can you provide the link to this level? Power Peak isn’t one that I recognize.

The problem here is that you’re trying to use the .on(‘eventType’, eventHandler) function with hero. Unfortunately that doesn’t work so you may have to just write your code for the hero in one while True loop separate from any function.
I hope this helps