[Solved] Why I cannot pass "LONG ROAD" with hints?


#1

I have seen this form, But I still cannot pass the stage.

# 右に移動
hero.moveXY(78, 35)
# この関数を達成:
def onSpawn(event):
    pass
    # なかにwhile-trueループ
    while True:
        # Use hero.findNearestItem()
        item = pet.findNearestItem()
        # もしそれらがアイテムなら:
        if item:
            # pet.fetch(item) を使って物を取る.
            pet.fetch(item)

# Use pet.on() to assign onSpawn to the "spawn" event
pet.on("spawn", onSpawn)

It seems the pet cannot find item, it won’t fetch item.
How can I make the pet fetch items?


#2

It is just that pets don’t have acces to the function findNearestItem()

you can use pet.findNearestByType(“potion”)
or even hero.findNearestItem() could work too


#3

Thank you, Gabriel for replying me.[

quote=“Gabriel_Dupuis, post:2, topic:14345”]
pet.findNearestByType(“potion”)
[/quote]

I have used it, but the pet cannot find potions.


# 右に移動
hero.moveXY(78, 35)
# この関数を達成:
def onSpawn(event):
    pass
    # なかにwhile-trueループ
    while True:
        # Use hero.findNearestItem()
        item = pet.findNearestByType("potion")
        # もしそれらがアイテムなら:
        if item:
            # pet.fetch(item) を使って物を取る.
            pet.fetch(item)

# Use pet.on() to assign onSpawn to the "spawn" event
pet.on("spawn", onSpawn)

#4

Oh I see the problem, you are using hero.moveXY at the beginning so no code will happen until the hero as reached location


#5

You said correct! Thank you. I passed the stage.

This is the solution of Long Road

(Solution removed)


#6

It’s great that you finished the level but please don’t post finished code or final solutions. The purpose of this board is to help people figure out the solutions themselves so they can learn. Simply providing solutions/code is counterproductive to the main goal. Thank you.