I’m currently stuck on bookkeeper and I can’t remember or find out how to target only gold coins!
I have tried item.type == “gold”;
But nothing happens
I’m currently stuck on bookkeeper and I can’t remember or find out how to target only gold coins!
I have tried item.type == “gold”;
But nothing happens
Why are you trying to just collect gold? The directions say to, “collect coins until the clock reaches 30 seconds.” Coins add up to total gold, they just have varying values.
@MunkeyShynes is right you need to just collect coins. Answering your specific question you can target only gold:
while (true) {
var coin = hero.findNearestItem();
if (coin && (coin.bountyGold == 3) ) {
hero.move(coin.pos);
}
if (hero.time > 30) {
break;
}
}
or replace coin.bountyGold with coin.value
BUT the hero doesn’t collect any other gold coin. The level passes only if the first coin is a gold one . I don’t understand why the hero freezes. Same behavior with moveXY. Another question: what is the difference between bountyGold and value?
literally no difference (bountyGold might be a protected property while value isn’t tho)
u should do hero.findByType(“gold-coin”) to get an array of gold coins
I tried this:
var items = hero.findItems();
if (items.lenght > 0){
var goldCoins = hero.findByType('gold-coin', items);
if (goldCoins.lenght > 0){
var goldCoin = hero.findNearest(goldCoins);
hero.move(goldCoin.pos);
}
}
and it doesn’t work…
/PS : I passed this level collecting all coins last year/
of course it doesn’t work. You misspelled length. (idk about javascript but in Python u use len(goldCoins) instead of goldCoins.length)
True it’s a mess in my head trying to learn python, java-script and coffee-script at the same time but this is really java-script
Thank you to everyone who replied. I actually learned a few things reading the responses.
I was for sure over thinking this level.
I woke up this morning reread the instructions and reset my code and completed it on the first try.
Thanks again!