Moveto
opened this issue · comments
Deleted user commented
I have an array with several game coordinates (x, y, z)
My doubt is
How to check if the char arrived at the coordinate sent for me to send the next array list coordinate
Currently mine is already going straight to the last coordinate of the list is making the char get stuck in some obstacle.
l2.moveTo (x1, y1, z1) // got here?
l2.Me.MovingVector // ??
l2.moveTo (x2, y2, z2) // go to the next one in the list.
Nick commented
I would suggest a custom moveTo
function similar to this:
const moveTo = (x: number, y: number, z: number, timeoutSec = 20) => {
return new Promise((resolve, reject) => {
l2.moveTo(x, y, z);
const t = setInterval(() => {
if (Math.abs(l2.Me.X - x) <= 50 && Math.abs(l2.Me.Y - y) <= 50) {
resolve(true);
clearInterval(t);
}
timeoutSec--;
if (timeoutSec <= 0) {
reject("Timeout on moving to location.");
clearInterval(t);
}
}, 1000);
});
};