About treasure-cave


var item = this.findItems();
var enemy = this.findNearest(this.findEnemies());

this.buildXY(“fire-trap”, 44, 8);

this.pos =
var xi = this.pos.x; ←I don’t know why this part is error?
var yi = this.pos.y;
this.moveXY(xi, yi);


Before that line you have an incorrect assignment. Where is the value right of the equal?
this.pos =

Sometimes the error is actually in the preceding lines. The compiler is thrown off-track and tries to make sense of what you wrote. When it gives up, the error reported might not be the real cause.
For syntax errors (sort of “spelling” errors on the code conventions) look also before the error point.

If you have a warning (a yellow triangle) or an error (a red X) showing on the right of your code lines, move the mouse cursor over and a floating text will tell you more about the error.
Usually is “expecting something”. That something is a symbol ),},; right-value etc. required by the correct instruction syntax


Without jumping into treasure-cave (I’m not a subscriber currently) I see a couple things here.
First, you gather an array of items and stuff it into a var called item. If there are more than one items on the map you’re going to need to use a loop to iterate through the items individually.

Tip: all Objects collected have an element called “pos” (Your Hero also has an element called pos, so defining it as this.pos is unnecessary as it will always be updated with your current x/y co-ordinates)

I imagine “xi” and “yi” are intended to be representative of iterations through the item array?

you would want to loop through your “item” variable and do something along the lines of.

xi = item[itemIndex].pos.x;
yi = item[itemIndex].pos.y;

Also remember this.summon(“soldier”) has a gold cost. I won’t tell you how to define or check that cost (the API notes for the boss star tells you that.) But you will want to check that you can afford the soldier before summoning it.
if(enemy && this.gold > valCost){