Getting "IsPathClear" to work in the level stranded in the dunes

// 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});
}

I contentiously get the error,“cant read protected property:move.” I looked around elsewhere and before I would get the error,“cant read protected property finditem” But I stumbled on a forum that mentioned upgrading/downgrading your glasses. Which lead me to the second error, my previous error, but I tried to swap out my boots as I did my glasses. But that didn’t fix anything this time.

What boots are you wearing? You have to have appropriate boots that have the move skill

may I please know how do you use “isPathClear” ?

hero.isPathClear(start, end)

how do you use it?

IsPathClear checks if the path between two points is clear. You therefore need to enter the two points that it’s checking. You do not do that by just putting in XY coordinates like this: ((55, 62), (8, 99)), as if it’s two moveXYs or the like. Hold your hat, and I’ll try to explain it to the best of my meager ability.

The longhand way to put it in (using the numbers from the last example) is as such: ({'x': 55, 'y': 62}, {'x': 8, 'y': 99}). This can get tedious, at least if you’re as lazy as me, so you may want to strategically use cut and paste. Let’s say, however, that (55, 62) is where your hero is; then you have a shortcut, as your hero’s coords are stored in just this format in hero.pos, meaning you can just write ({hero.pos}, {'x': 8, 'y': 99}), saving your fingers all those extra calories. This would also be true if the second set of coords are for some item, friend or enemy; you could just use their pos.

I hope I got that all right myself, but the community will probably step in if I didn’t.

1 Like