Бэквудский лес Долгая дорога

Проблема с кодом. Питомец не собирает зелье. Ошибка указателя. Что я не так делаю?

# Иди направо.

# Заверши эту функцию:
def onSpawn(event):
    pass
    # Внутри цикла `while-true`:
    while-true:
        # Используй `hero.findNearestItem()`
        potion = pet.findNearestItem()
        # Если есть предмет:
        if potion:
            # Используй `pet.fetch(item)`, чтобы взять предмет.
            pet.fetch("potion")

# Используй `pet.on()`, чтобы назначить функцию на событие "spawn"
pet.on("spawn", onSpawn)   
hero.moveXY(78, 35)
type or paste code here

Возможно, питомец не может найти ближайший предмет, поэтому вместо pet.findNearestItem() используйте hero.findNearestItem().

The pet probably can’t find the nearest item, so instead of pet.findNearestItem(), use hero.findNearestItem().

Также удалите строку из pet.fetch("potion").

Also, remove the string from the pet.fetch("potion").

hey @abc tell @11180 that he need to tell the pet to find by type not the hero

Yo don’t need to do that, you can just have the hero find the nearest.

okay but I usually do it the other way

Я вообще запутался. Что мне нужно, а что не нужно делать? Напишите пожалуйста все в одном сообщении, а то так трудно разобраться.

Вам нужно будет заменить potion = pet.findNearestItem() на potion = hero.findNearestItem() или вы можете заменить его на potion = pet.findNearestByType("potion"). Вам также необходимо удалить строку из pet.fetch("potion"), поскольку это должно быть pet.fetch(potion).

You will need to replace potion = pet.findNearestItem() with potion = hero.findNearestItem() or you can replace it with potion = pet.findNearestByType("potion"). You also need to remove the line pet.fetch("potion") as it should be pet.fetch(potion).

Если так, то все равно не работает.

# Иди направо.

# Заверши эту функцию:
def onSpawn(event):
    pass
    # Внутри цикла `while-true`:
    while-true:
        # Используй `hero.findNearestItem()`
        potion = hero.findNearestItem()
        
        # Если есть предмет:
        if potion:
            # Используй `pet.fetch(item)`, чтобы взять предмет.
            pet.fetch(potion)

# Используй `pet.on()`, чтобы назначить функцию на событие "spawn"
pet.on("spawn", onSpawn)
hero.moveXY(78, 35)
type or paste code here

Измените свой цикл while true с

while-true:

к

while True:

и удалите это

type or paste code here
1 Like

Спасибо большое! Код работает. Но в чем разница между " while-true" и “while True” ? Объясните пожалуйста.
(type or paste code here - это не строка. В моем коде ее нет. Она добавляется автоматически к сообщению)

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.