Arrowproof Wolf - Help

I changed my code several times and I always run out of time.
I also noticed that it seems I do not have a pet, even though I selected one before the game started.

This is my code:

Collect mushrooms.

First, come to the wolf pet and wake up it (say).

hero.say(“Wake up”)
while True:
arrow = hero.findNearest(hero.findEnemyMissiles())
item = hero.findNearestItem()
if item:
hero.moveXY(item.pos.x, item.pos.y)
elif arrow:
pet.catch(arrow)

Please help, I am stuck.
Thanks

Do you have a wolf or not? The level kinda requires a wolf, as the name implies. But if you look at the hints (yeah, these are important) it clearly says,

ArrowProofWolfHint

I wrote no code for the wolf when I did it.

Also, did you just shout from across the clearing or did you follow the directions and, “come to it and say something.”

1 Like

got it right now!
Thank you!

Hello! That’s my code. I’m still learning English language, pardon me pls if got some mistakes :slight_smile:

hero.moveXY(12, 34)
hero.say(“Hello wolfy, wake up!”)

def onSpawn(event):
spear = pet.findNearestByType(“spear”)
pet.catch(spear)
pass
while True:
item = hero.findNearestItem()
if item:
pet.on(“spawn”, onSpawn)
itemPosition = item.pos
itemX = itemPosition.X
itemX = itemPosition.Y
hero.move(item.pos)
It’s work, and I’ve done this level, but have some problems with understanding why I’ve got “ReferenceError”. Pls, help. Thanks.

Hi beoatch,

Welcome to the forum!

I think you are getting the error from:

pet.findNearestByType(“spear”)

When I try it, “spear” is not recognised by the programme. Does the error go away if you delete that line (and the line beneath as well)?

In future when you’re posting, could you click on this button image and paste your code inside the dots so that it is formatted properly?

Thanks,

Jenny

Hi Jenny! “spear” really worked, but with “arrow” no result :D, maybe some bugs? I’ll send you screen btw.
P.S. sorry for my English, learning =)

вс, 1 нояб. 2020 г. в 14:58, Jenny via CodeCombat Discourse <codecombat@discoursemail.com>:

hero.moveXY(12, 34)
hero.say(“Wake up”)

while True:
item = hero.findNearestItem()
arrow = hero.findNearest(hero.findEnemyMissiles())
if item:
hero.moveXY(item.pos.x, item.pos.y)
else:
pet.catch(arrow)