Can't Read Protected Property


#1

This code was added in automatically, yet it states that something is wrong with it There is no bug in the code, so what’s wrong with it?


#2

Never mind, I understand now :slight_smile:


#3

I don’t understand, what’s the problem? I have that exact same error right now.


#4

You probably don’t have the method that you are trying to execute. For example, the findNearestItem method is not available if your glasses are too good, you then need hero.findNearest(hero.findItems()). Similarly for findNearestFriend / Enemy. You also won’t have a buildXY method if you are not equipping a hammer.


#5

I upgraded or / downgraded my glasses which than gave me “protected property : move” I tried the same thing with the boots, but the problem was not fixed.


#6
// Check the guide for more details.
var item = hero.findNearest(hero.findItems());
if (item && hero.isPathClear(hero.pos, item.pos)) {
    hero.move(item.pos);

}
else {
hero.move({x: hero.pos.x, y: hero.pos.y + 5});
}

#7

Does there has to be an item, or will he constantly move until an item is found? Could that maybe be the issue?


#8

I have constantly switched between the two key words “this” and “hero” in order to fix the protected property:move error.


#9

@gat Are you getting an error about the move property? If so, you need to equip boots that provide the move method, that is, Compound Boots or above.


#10

I currently have soften leather boots equipped on my wizard. And the boots say,“skills granted moveXY”.


#11

moveXY and move are two different methods. :slight_smile:


#12

ohhh I didn’t see there was a third move as in this.move. I kept only seeing this.moveXY and this.moveDown, up, left, and right etc The fine boots did it thank you. :slight_smile: