[SOLVED] Passing through HELP please!


#1

Hi guys,:blush:
can’t complete Passing Through level.


it says: Cant read property ‘pos’ of null
here is my code:

while(true) {
    var item = hero.findNearestItem();
    if(item) {
        // If item.type IS NOT EQUAL TO "gem"
        if(item.type != "gem") {
            // Then follow your pet wolf.
            hero.moveXY(pet.pos.x, pet.pos.y);
        }
        // Else:
    } else {
            // Move to the gem's position.
           hero.moveXY(item.pos.x, item.pos.y);
        
    }
}

thx!


#2


#3

sorry, first time here.

while(true) {
    var item = hero.findNearestItem();
    if(item) {
        // If item.type IS NOT EQUAL TO "gem"
        if(item.type != "gem") {
            // Then follow your pet wolf.
            hero.moveXY(pet.pos.x, pet.pos.y);
        }
        // Else:
    } else {
            // Move to the gem's position.
           hero.moveXY(item.pos.x, item.pos.y);
        
    }
}


#4
while(true) {
    var item = hero.findNearestItem();
    if(item) {
        // If item.type IS NOT EQUAL TO "gem"
        if(item.type != "gem") {
            // Then follow your pet wolf.
            hero.moveXY(pet.pos.x, pet.pos.y);
        }
        // Else:
     else {
            // Move to the gem's position.
           hero.moveXY(item.pos.x, item.pos.y);
        }
    }
}

#5

oh, wrong placed { }
Thanks, man, really appreciate your help!