I modified my code from Spring Thunder to prioritize coins in order of their value. This code works fine in the Spring Thunder level;
while (true) {
var item = hero.findNearestItem();
if (item.type == “coin” && item.value == 3 && hero.distanceTo(item) < 3) {
hero.moveXY(item.pos.x, item.pos.y);
} else if (item.type == “coin” && item.value == 2 && hero.distanceTo(item) < 3) {
hero.moveXY(item.pos.x, item.pos.y);
} else if (item.type == “coin”) {
hero.moveXY(item.pos.x, item.pos.y);
}
}
However when I run this exact same code on Multiplayer Treasure Grove I get a Line3 TypeError: Cannot read property ‘type’ of null. I don’t understand how the code works exclusively on one level.