After over an hour of work, I got the message no one wants to get: “There is a problem with your code.” It doesn’t even say where the problem is! Anyway, here’s my code:
var firetraps = hero.findByType("fire-trap");
var beartraps = hero.findByType("bear-trap");
var f1 = [];
var f2 = [];
var b = [];
function findPrimes(number) {
for (var i = 2, i < Math.ceil(Math.sqrt(number.value)); i ++) {
if (number.value % i == 0) {
return false;
}
}
return true
}
for (var x = 0; x < firetraps.length; x ++) {
var firetrap = firetraps[x];
if (firetrap.pos.y > 30) {
if (findPrimes(firetrap) === true) {
f1.push(firetrap);
}
}
else {
if (findPrimes(firetrap) === true) {
f2.push(firetrap);
}
}
}
for (var y = 0; y < beartraps.length; y ++) {
var beartraps = beartraps[y];
if (findPrimes(beartrap) === true) {
b.push(beartrap);
}
}
var friends = hero.findFriends();
for (var c = 0, c < f1.length; c ++) {
var trap1 = f1[c];
if (trap1) {
hero.moveXY(trap1.pos.x + 10, trap1.pos.y);
hero.moveXY(trap1.pos.x, trap1.pos.y);
hero.moveXY(trap1.pos.x - 10, trap1.pos.y);
for (var m = 0; m < friends.length; m ++) {
var friend = friends[m]
hero.command(friend, "move", {'x': trap1.pos.x + 10, 'y': trap1.pos.y});
hero.wait(1);
hero.command(friend, "move", {'x': trap1.pos.x, 'y': trap1.pos.y});
hero.wait(1);
hero.command(friend, "move", {'x': trap1.pos.x - 10, 'y': trap1.pos.y});
}
}
}
for (var d = 0, d < f2.length; d ++) {
var trap2 = f2[d];
if (trap2) {
hero.moveXY(trap2.pos.x - 10, trap2.pos.y);
hero.moveXY(trap2.pos.x, trap2.pos.y);
hero.moveXY(trap2.pos.x + 10, trap2.pos.y);
for (var n = 0; n < friends.length; n ++) {
var friend = friends[n]
hero.command(friend, "move", {'x': trap2.pos.x - 10, 'y': trap2.pos.y});
hero.wait(1);
hero.command(friend, "move", {'x': trap2.pos.x, 'y': trap2.pos.y});
hero.wait(1);
hero.command(friend, "move", {'x': trap2.pos.x + 10, 'y': trap2.pos.y});
}
}
}
for (var e = 0, e < b.length; e ++) {
var trap3 = f2[e];
if (trap3) {
hero.moveXY(trap3.pos.x - 10, trap3.pos.y);
hero.moveXY(trap3.pos.x, trap3.pos.y);
hero.moveXY(trap3.pos.x + 10, trap3.pos.y);
for (var o = 0; o < friends.length; o ++) {
var friend = friends[o]
hero.command(friend, "move", {'x': trap3.pos.x - 10, 'y': trap3.pos.y});
hero.wait(1);
hero.command(friend, "move", {'x': trap3.pos.x, 'y': trap3.pos.y});
hero.wait(1);
hero.command(friend, "move", {'x': trap3.pos.x + 10, 'y': trap3.pos.y});
}
}
}
It’s a bit extensive, but as far as I can tell, the functions are complete, and none of the commands are incomplete. I’ve extinguished my list of what to check. I must have gotten something wrong, though … any help?