Pet.fetch multiple [Javascript]


#1

Hi there so question about this code, is there a way I can get my pet to pick up multiple items?

function onSpawn(event) {
    // The pet should find and fetch three keys.
    // You need items with the next types:
    // "bronze-key", "silver-key" and "gold-key".
    var bk = pet.findNearestByType("bronze-key");
    var sk = pet.findNearestByType("silver-key");
    var gk = pet.findNearestByType("gold-key");
    var key = bk + sk + gk;
    pet.fetch(bk && sk && gk);
    //pet.fetch(sk);
   // pet.fetch(gk);
}

Now I was thinking of putting it as || (or) and adding it to a while true loop, I tried writing it as “pet.fetch(bk, sk, gk);”, I tried “pet.fetch(key);” I’m guessing I am just coming up on array levels so thinking this is going to be an array thing later? If so no spoilers!! lol joking


#2

no, a pet cannot hold multiple items, you have to carry them one by one.


#3

Is there a shortened form of the pet carrying them one by one?


#4
var item = hero.findNearestItem();
while (item)
    pet.fetch(item)
    var item = hero.findNearestItem();

#5

Oh derp lol thanks Seojin! I feel like deleting my topic that was so basic xD