You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bot.on('chat',function(username,message){constpos=bot.entity.position;if(username===bot.username)returnconsttarget=bot.players[username] ? bot.players[username].entity : nullif(message==='come'){if(!target){bot.chat('I don\'t see you !')return}constp=target.positionbot.pathfinder.setMovements(defaultMove)// This line worksbot.pathfinder.setGoal(newGoalNear(p.x,p.y,p.z,1))bot.once('goal_reached',async()=>{console.log('Arrived, returning')// Prints "Arrived, returning" correctly when it has arrivedbot.pathfinder.setGoal(newGoalNear(pos.x,pos.y,pos.z,1))// Doesn't path and pathfinder sends a status of timeout});}})asyncfunctionsleep(ms){returnnewPromise((resolve)=>setTimeout(resolve,ms))}
Slightly modified code from example. But it has a problem, I need to add an await sleep(0), after console.log, because if I don't add it, it will timeout, this doesn't happen when I actually add an await sleep(0), like this:
bot.on('chat',function(username,message){constpos=bot.entity.position;if(username===bot.username)returnconsttarget=bot.players[username] ? bot.players[username].entity : nullif(message==='come'){if(!target){bot.chat('I don\'t see you !')return}constp=target.positionbot.pathfinder.setMovements(defaultMove)bot.pathfinder.setGoal(newGoalNear(p.x,p.y,p.z,1))bot.once('goal_reached',async()=>{console.log('Arrived, returning')awaitsleep(0)// Arrives, logs "Arrived, returning"bot.pathfinder.setGoal(newGoalNear(pos.x,pos.y,pos.z,1))// And pathfind works});}})asyncfunctionsleep(ms){returnnewPromise((resolve)=>setTimeout(resolve,ms))}
The text was updated successfully, but these errors were encountered:
We have this code:
Slightly modified code from example. But it has a problem, I need to add an await sleep(0), after console.log, because if I don't add it, it will timeout, this doesn't happen when I actually add an await sleep(0), like this:
The text was updated successfully, but these errors were encountered: