Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Bug On Underground Buissness?


So… Below Is My Code. It Should Work, But I get a Message Saying “Try hero.pos” On Line 18. I Don’t Know Why! Is This A Bug? Please Help.

// Accumulate 300 gold and escape from the dungeon.

function onSpawn(event) {
    // Send the pet to walk around the dungeon:
    var coin = pet.findNearestByType("gold-coin");
    // Don't forget to return it to the hero:

pet.on("spawn", onSpawn);

while(true) {
    // Guard peasants:
        var enemy = hero.findNearestEnemy();
        if (enemy) {
    // When you have 300+ gold move to the red mark:
        if ( > 300) {
            hero.moveXY(50, 34);


It’s a bug in your code. You try to send the pet to coin. Are you sure that a coin exists?


Before I Talk About The Code, I want to tell this is the same guy as The99thMage, I forgot my password and the reset email didn’t come. Well, Now I used This:


But Now The Mimic Pet Moves Just A Little Before stopping


You pet doesn’t see any coin so as the result it’s moving to the hero position.

Have you read comments/instructions? Why do you want use coin.pos?


I am struggling a bit too. Are we supposed to manually instruct the pet to move around the box using moveXY and hardcoding in the parameters? If not, how come my pet cannot see “coin”.

    var coin = pet.findNearestByType("gold-coin");
    if (coin) {
        pet.moveXY(coin.pos.x, coin.pos.y);

I put that inside onSpawn().


For the current level it’s the best way. If you will try to follow by coins without any condition your pet will stuck.