hello, in “chase them” the couger says “i cannot carry that” on potion… ? stage is simple, dont understand what could go wrong… also - cant change couger if it makes any difference
i tried simple
pet.fetch("potion");
and
javascript
// Find and fetch a "potion":
var item = pet.findNearestByType("potion");
if (item.type==="potion") {
pet.fetch("potion");
// Find and fetch a "potion":
var potion = pet.findNearestByType("potion"); # There are other items too
if (item.type==="potion") { # Why did you put three equals?
pet.fetch("potion"); # Put potion instead, if you use a string
# then why did you define potion (item)
from turtle import *
screen = Screen() # You define it like this '==' means equal, '=' means assign
screen.setup(400, 400)
screen.bgcolor('dodge blue')
// You always need to define, heres a piece of script I used when playing games
(function(){//info
if(window.updateInfo) return;
var info = {};
var info_container = document.createElement("div");
info_container.style.position = "fixed";
info_container.style.color = "white";
info_container.style["pointer-events"] = "none";
document.body.appendChild(info_container);
function toggle_info_container(e){
if(e.key == "i"){
info_container.style.display = info_container.style.display=="block" ? "none" : "block";
}
}
window.addEventListener("keyup", toggle_info_container);
ive been trying different stuff since most basic didnt work (answering to why did i === for exeple)
javascript
function onSpawn(e) {
while (true) {
var enemy = pet.findNearestByType("munchkin");
if (enemy && pet.isReady("chase")) {
pet.chase(enemy);
}
// Find and fetch a "potion":
var nearest = pet.findNearestByType("potion");
pet.fetch("potion");
}
}
when there was “nearest” instead of " “potion” " couger actually did go for the potions BUT it went for the second potion as well without waiting for cooldown of chase thus he braught both potions but 1 ogre stayed,
code works fully after i moved in the loop code solution deleted
i understand the logic here of the loop, I just try to follow instructions in their order unless i dont make it work i improvise, i would have expected for “fetch(“potion”)” to work tho, potion is a constant the game recognizes, doesnt it?
“potion” is a string (text in quotes), a type of item. You want to target an object. A thing in the game, like a friend, and enemy or an item. The object’s name doesn’t represent it exactly.
Earlier you were able to attack a specific enemy e.g. hero.attack(“Kronk”), “potion” isn’t a specific thing, unlike “Kronk”.
Danny