[Adventurer] Sand mushrooms


#1

The new desert level about pets: Sand Mushrooms.

Pets don’t have findNearestItem method, but they have findNearestByType. This level opens the series about this useful method.

Learn your pet to distinguish potions and mushrooms.


#2

I have in my Inventory Wolf Pup but in Level is my Pet Baby Griffin …


#3

Yep. Because this level requires a flying pet, but it’s not unlocked as an “item” yet. So you have the griffin pet for “free” on this level.


#4

Played this level just now, and I loved it.
It’s simple enough for me to understand (Not very good at coding, started a few days ago) yet still shows you how to do things.


#5

my raven said: “I can’t carry that!” :frowning_face:


#6

Sorry for necroposting but I am currently stuck on this level. I cannot select play and it wants me to use the crow but I cannot select it because I am not subscribed.

Obvious answer would be to subscribe but with other levels I could always play and get a random pet assigned (as noted above by Bryukh). Am I missing something or is this a bug?


#7

Ok found it, instead of double clicking the raven, you should drag and drop it.


#8

about that raven, it could not carry the potion :rage:


#9

I am on level 33 by the way :sweat_smile:


#10

@Caleb_Soo Maybe something wrong in your code?


#11

@Bryukh here’s my code:

def onSpawn(event):
    while True:
        potion = pet.findNearestByType("potion")
        pet.fetch("potion")

pet.on("spawn", onSpawn)

while True:
    someItem = hero.findNearestItem()
    if someItem and hero.health > hero.maxHealth / 3:
        hero.moveXY(someItem.pos.x, someItem.pos.y)
        pass

#12

I am not so sure anyways :frowning:


#13

Could you post your code? The raven can carry potions as any other pets. They use the same component for that.


#14

@Caleb_Soo have you played levels before that one? Do you know the difference between a variable and a string? Pets need the certain item variable, not its type to fetch


#15

For example, you need to pass an object:

var item = pet.findNearestItem();
pet.fetch(item);

#16

yes I do…:neutral_face:


#17

potion = pet.findNearestByType(“potion”) was default


#18

now i am stuck on the someItem part :confused:


#19

Shouldn’t it be

potion = pet.findNearest(pet.findByType("potion"))
pet.fetch(potion)

#20
potion != "potion"

findNearestByType gets a string (type) as an argument. pet.fetch needs an item (object) as an argument. For some commands as attack you can use a string or a unit as an argument, but if you use a string it should be the ID (name) (not type).