Need help with an error that will not go away


#1

have an error that will not go away it says “Unhandled error: TypeError: Cannot read property ‘isEllipse’ of undefined”


#2

Please post your code. We can’t help you if we can’t see the reason for the error. Don’t forget to use the </> button to format it properly.


#3

here is the code

def onSpawn(event):
unit = event.target
while True:
enemy = unit.findNearestEnemy()
if enemy:
unit.attack(enemy)

player = game.spawnPlayerXY(“guardian”, 44, 59)
player.maxHealth = 15
player.attackDamage = 50
player.maxSpeed = 3
ui.track(player, “health”)

game.addSurviveGoal()
game.addCollectGoal()
game.addDefeatGoal()

game.setActionFor(“thrower”, “spawn”, onSpawn)
game.setActionFor(“ogre”, “spawn”, onSpawn)
game.setActionFor(“scout”, “spawn”, onSpawn)

generator1 = game.spawnXY(“generator”, 61, 15)
generator1.spawnType = “munchkin”

game.spawnMaze(“clump”, 4)
game.spawnXY(“clump”, 52, 28)
game.spawnXY(“clump”, 28, 20)

Bob = game.spawnXY(“ogre-f”, 19, 59)

scout1 = game.spawnXY(“scout”, 30, 11)
scout1.attackDamage = 1
thrower1 = game.spawnXY(“thrower”, 60, 54)
thrower1.attackDamage = 1
thrower2 = game.spawnXY(“thrower”, 28, 51)
thrower2.attackDamage = 1

fireSpewer1 = game.spawnXY(“fire-spewer”, 52, 44)
fireSpewer1.spamInterval = 4
fireSpewer1.spamEvery = 0.1

fireSpewer2 = game.spawnXY(“fire-spewer”, 52, 28)
fireSpewer2.spamInterval = 4
fireSpewer2.spamEvery = 0.1

fireSpewer3 = game.spawnXY(“fire-spewer”, 10, 5)
fireSpewer3.direction = “vertical”

fireSpewer4 = game.spawnXY(“fire-spewer”, 14, 5)
fireSpewer4.direction = “vertical”

trap1 = game.spawnXY(“fire-trap”, 17, 13)
trap1.attackDamage = 3

trap2 = game.spawnXY(“fire-trap”, 17, 9)
trap2.attackDamage = 3

trap3 = game.spawnXY(“fire-trap”, 25, 13)
trap3.attackDamage = 3

trap4 = game.spawnXY(“fire-trap”, 50, 29)
trap4.attackDamage = 3

game.spawnXY(“chest”, 28, 28)
game.spawnXY(“potion-small”, 22, 28)

game.spawnXY(“gold-coin”, 44, 29)
game.spawnXY(“gold-coin”, 44, 39)
game.spawnXY(“gold-coin”, 44, 49)
game.spawnXY(“gold-coin”, 44, 13)
game.spawnXY(“gold-coin”, 52, 59)
game.spawnXY(“gold-coin”, 44, 20)
game.spawnXY(“gold-coin”, 60, 49)
game.spawnXY(“gold-coin”, 60, 59)
game.spawnXY(“gold-coin”, 60, 28)
game.spawnXY(“gold-coin”, 60, 39)
game.spawnXY(“gold-coin”, 35, 12)
game.spawnXY(“gold-coin”, 26, 12)
game.spawnXY(“gold-coin”, 12, 19)
game.spawnXY(“gold-coin”, 12, 27)
game.spawnXY(“gold-coin”, 12, 35)
game.spawnXY(“gold-coin”, 12, 43)
game.spawnXY(“gold-coin”, 12, 12)
game.spawnXY(“gold-coin”, 21, 44)
game.spawnXY(“gold-coin”, 28, 44)
game.spawnXY(“gold-coin”, 28, 60)
game.spawnXY(“chest”, 12, 60)
game.spawnXY(“chest”, 60, 10)


#4

Please learn to post your code properly. It’s really easy and only requires a very small amount of effort.

To post your code from the game, use the </> button or it won’t format properly. When you click the </> button, the following will appear:

Please paste ALL of your code inside the triple back tick marks.

``` <— Triple back tick marks.

Paste ALL of your code in here.

``` <— Triple back tick marks.

There are many people here willing and able to help. If you use the </> button correctly, then ALL of your code should look like this:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    else:
        hero.say("My code is formatted properly")

If ALL of your code isn’t formatted like the code above, then you’re doing it wrong and we can’t see the structure of the code to troubleshoot whether or not that is the issue. Use the </> button and help us help you. This works when sending a private message as well.

Thank you.


#5

def onSpawn(event):
    unit = event.target
    while True:
        enemy = unit.findNearestEnemy()
        if enemy:
            unit.attack(enemy)

player = game.spawnPlayerXY("guardian", 44, 59)
player.maxHealth = 15
player.attackDamage = 50
player.maxSpeed = 3
ui.track(player, "health")

game.addSurviveGoal()
game.addCollectGoal()
game.addDefeatGoal()

game.setActionFor("thrower", "spawn", onSpawn)
game.setActionFor("ogre", "spawn", onSpawn)
game.setActionFor("scout", "spawn", onSpawn)


generator1 = game.spawnXY("generator", 61, 15)
generator1.spawnType = "munchkin"


game.spawnMaze("clump", 4)
game.spawnXY("clump", 52, 28)
game.spawnXY("clump", 28, 20)


Bob = game.spawnXY("ogre-f", 19, 59)

scout1 = game.spawnXY("scout", 30, 11)
scout1.attackDamage = 1
thrower1 = game.spawnXY("thrower", 60, 54)
thrower1.attackDamage = 1
thrower2 = game.spawnXY("thrower", 28, 51)
thrower2.attackDamage = 1


fireSpewer1 = game.spawnXY("fire-spewer", 52, 44)
fireSpewer1.spamInterval = 4
fireSpewer1.spamEvery = 0.1


fireSpewer2 = game.spawnXY("fire-spewer", 52, 28)
fireSpewer2.spamInterval = 4
fireSpewer2.spamEvery = 0.1


fireSpewer3 = game.spawnXY("fire-spewer", 10, 5)
fireSpewer3.direction = "vertical"


fireSpewer4 = game.spawnXY("fire-spewer", 14, 5)
fireSpewer4.direction = "vertical"

trap1 = game.spawnXY("fire-trap", 17, 13)
trap1.attackDamage = 3
trap2 = game.spawnXY("fire-trap", 17, 9)
trap2.attackDamage = 3
trap3 = game.spawnXY("fire-trap", 25, 13)
trap3.attackDamage = 3
trap4 = game.spawnXY("fire-trap", 50, 29)
trap4.attackDamage = 3
game.spawnXY("chest", 28, 28)
game.spawnXY("potion-small", 22, 28)


game.spawnXY("gold-coin", 44, 29)
game.spawnXY("gold-coin", 44, 39)
game.spawnXY("gold-coin", 44, 49)
game.spawnXY("gold-coin", 44, 13)
game.spawnXY("gold-coin", 52, 59)
game.spawnXY("gold-coin", 44, 20)
game.spawnXY("gold-coin", 60, 49)
game.spawnXY("gold-coin", 60, 59)
game.spawnXY("gold-coin", 60, 28)
game.spawnXY("gold-coin", 60, 39)
game.spawnXY("gold-coin", 35, 12)
game.spawnXY("gold-coin", 26, 12)
game.spawnXY("gold-coin", 12, 19)
game.spawnXY("gold-coin", 12, 27)
game.spawnXY("gold-coin", 12, 35)
game.spawnXY("gold-coin", 12, 43)
game.spawnXY("gold-coin", 12, 12)
game.spawnXY("gold-coin", 21, 44)
game.spawnXY("gold-coin", 28, 44)
game.spawnXY("gold-coin", 28, 60)
game.spawnXY("chest", 12, 60)
game.spawnXY("chest", 60, 10)

#6

You don’t make them attack(enemy) instead, you set their behavior to AttacksNearest with capitals.