var less = 'Nimis';
var more = 'Non satis';
var requiredGold = 104;
function sumCoinValues(coins) {
var i = 0;
var total = 0;
while (i < coins.length) {
total += coins[i].value;
i++;
}
return total;
}
while (true) {
var items = hero.findItems();
var goldAmount = sumCoinValues(items);
if (items.length !== 0) {
if (goldAmount < 104) {
hero.say('Non satis');
}
if (goldAmount > 104) {
hero.say('Nimis');
}
if (goldAmount == 104) {
hero.say(goldAmount);
loop {
var coins = hero.findItems();
var index = 0;
var nearestDistance = 9999;
var nearest = coin;
while (index < coins.length) {
var coin = coins[index];
index += 1;
var distance = hero.distanceTo(coin);
if (distance < nearestDistance) {
nearest = coin;
nearestDistance = distance;
}
}
hero.moveXY(nearest.pos.x, nearest.pos.y);
}
}
}
}
My hero waits until the value of the coins is 104 and then collects them all in an efficient manner, well before the time runs out, but the level won’t let me pass and keeps saying I’ve run out of time. Is this is a bug or am I missing something?
I’m pleased it’s working for you, suggests my code is ok. Still not working this end and nothing in the Dev console as far as I can see. Thanks for the reply.
Thanks! It helped. At least I reproduced that bug. You didn’t equip any “boss star”. Of course, you don’t have to do it and it’s definitely a bug, but now I know where to search. I will write you when I solve it.