Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Forest Fire Dancing Help (JavaScript)

#1

Hi I have a problem with level Forest Fire Dancing.
Can you identify the problem with code?

while (true) {
var evilstone = hero.findNearestItem();
if (evilstone) {
var pos = evilstone.pos;
if (pos.x == 34) {
hero.moveXY(46, 22);
} else {
var evilstone = hero.findNearestItem();
}
if (evilstone) {
var pos = evilstone.pos;
if (pos.x == 46) {
hero.moveXY(34, 22);
}
} else {
var evilstone = hero.findNearestItem();
if (!evilstone) {
hero.move(40, 22);
}
}
}
}

P.S. Sorry if my engilsh is bad.

#2

if (!evilstone) {
hero.move(40, 22); hero.moveXY(x,y)

#3

That still doesn’t help…

#4

I just tried it and it still doesn’t work.

#5

You only have to find the evilstone and the pos once so you can remove all the other times you look for it to clean up the code. When you get to the first else, just look at the second position.

if (pos.x == 46) {
hero.moveXY(34, 22);
}

The second else only needs to move the hero to the middle position.

To help with any formatting problems, you’ll need to format the code correctly when posting it.