Hello all,
I’m stuck on Sesame Path and I’m totally unsure as to how to proceed even after reading the Tips many times. I also know there was a question about this same level, but the help advice was to check the tips included on the level. This was enough to help the poster, but unfortunately I’m still struggling.
There is tons of code pre-included in the example and I’m just not sure what to add or modify.
I see that I’m supposed to check all directions with isPathClear, but that check already seems to be written in the supplied code. What am I missing? Many thanks!!
// Say "Open Sesame" and a door will open.
// Only doors near you will hear you.
// There is only one route without forks.
// The distance between each point is 24m.
var sesame = "Open Sesame";
var distance = 24;
var previous = "";
while (true) {
hero.say(sesame);
// Check each direction to see if the path is clear.
// Be sure to check and record your previous direction!
// Up
if(hero.isPathClear(hero.pos, hero.pos.add({x:0, y:24})) && previous != "down") {
hero.moveXY(hero.pos.x, hero.pos.y + 24);
previous = "up";
}
// Down
else if(hero.isPathClear(hero.pos, hero.pos.add({x:0, y:-24})) && previous != "up") {
hero.moveXY(hero.pos.x, hero.pos.y - 24);
previous = "down";
}
// Left
else if(hero.isPathClear(hero.pos, hero.pos.add({x:-24, y:0})) && previous != "right") {
hero.moveXY(hero.pos.x - 24, hero.pos.y);
previous = "left";
}
// Right
else if(hero.isPathClear(hero.pos, hero.pos.add({x:24, y:0})) && previous != "left") {
hero.moveXY(hero.pos.x + 24, hero.pos.y);
previous = "right";
}
}