in this level you have to collect coins while yaks are there, then hide when they are gone.
the problem is that I won’t stop collecting even after the yaks are gone.
here is the code :
// A desert storm is coming!
// Yaks can detect when a storm is coming.
// This variable will be used as a condition.
var yak = hero.findNearest( hero.findItems());
// While there is a sand yak:
while (yak) {
// Collect a coin.
var coin = hero.findNearest( hero.findItems());
if (coin) {
hero.moveXY(coin.pos.x, coin.pos.y);
}
// Update the variable "yak".
}
// The yaks have hidden.
// Move to the hideout.
hero.moveXY(38, 58);
how do I update the variable? what does it mean?
please help
Can you explain : then yak contains a value from the first frame. ?
In another way : what is the difference between first variable yak and the updated one?
I’m newbie and thanks for helping
On the first frame (first second, start the game etc) we definitely see yaks here. So yak variable contains the result of the findNearestEnemy.
But then the level state is changing and if you don’t update yak then it contains the result from the first call. So we need to recheck the state and write the new results of findNearestEnemy in the yak variable. It’s updated value.
One of the biggest sources of frustation with this teaching method is that the developers are in a high level of experience and they presume that they can instruct us about what should be done with simply a word or two. They replied this topic but for no avail. I simply cannot figure out what they wanted to say with the update yak thing. It´s just one exemple of ineffective communication between highly experienced staff and plain begginers. They presume too much about our current understanding.
Hello, welcome to the forum @knightcvel. If this post doesn’t help you with this level, you can start another with your specific questions. There are a lot of people with varying degrees of experience and not just the developers that can provide support.
If you need some advice, post your code and give some detail about the challenges you are having completing the level. We will help as much as we can. If there are some details that need more explanation we will try to provide the information as much as we understand with our experience in CodeCombat.