Problem with move(targetPos) Javascript

hello, I’m not sure if I’m doing anything wrong, but since I started the mountain and it got required to use the move() action I bought the “boots of leaping” and at the end am totally unable to use the move action? for example the “cloudrip commender” level (the 4th in the mountain")
this works

// Summon some soldiers, then direct them to your base.

// Each soldier costs 20 gold.
while (hero.gold > hero.costOf("soldier")) {
    hero.summon("soldier");
}
    
var soldiers = hero.findFriends();
var soldierIndex = 0;
// Add a while loop to command all the soldiers.
while(soldierIndex< soldiers.length) {
    var soldier = soldiers[soldierIndex];
    hero.command(soldier, "move", {x: 50, y: 40});
    soldierIndex ++;
}
// Go join your comrades!
hero.moveXY(50, 40);

while this doesn’t:

// Summon some soldiers, then direct them to your base.

// Each soldier costs 20 gold.
while (hero.gold > hero.costOf("soldier")) {
    hero.summon("soldier");
}
    
var soldiers = hero.findFriends();
var soldierIndex = 0;
// Add a while loop to command all the soldiers.
while(soldierIndex< soldiers.length) {
    var soldier = soldiers[soldierIndex];
    hero.command(soldier, "move", {x: 50, y: 40});
    soldierIndex ++;
}
// Go join your comrades!
hero.move({x: 50, y: 40});

the hero dosn’t even move… and the previous levels all asked me to use the move action and I had to go around it using moveXY because the hero just move sooooooo slowly with the move action

and then found this topic:

here
that speaks of this problem but it’s quite old. Is the bug still on or am i doing something wrong?
Thank you!
:slight_smile:

It may be because of the kind of boots you have in your inventory. It may also be a bug. I’ll invite @nick.

well just in case in my inventory I don’t have much:
-simple boots
-leather boots
-boots of leaping
and as I said, in some levels the hero moves slowly (for coin gathering for example) but in this last one, he doesn’t even move…
thanks for inviting nock if he’s the one who knows :yum:

That may be a bug. Try using all of your boots though

Well my other boots don’t have the move action…

Without while loop this command move your hero one frame only. Try to use moveXY.

2 Likes

Oh…ok . yeah try what @Bryukh said moveXY

Ok, I didn’t get this! move has to be used in a loop! :slight_smile:

It’s better to post the whole your code.

1 Like

Yep, move non-blocking moving, so it run for one frame only and then code continue to work. moveXY is blocking command and all your code is stop until you arrive at the point.

2 Likes

Yeah. To execute it multiple times.

you should use for loop to summon a soldier not while loop.:grinning: