Difference between revisions of "Bot Playground/Commands/walkTo"

From SmartBots Developers Docs
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 21: Line 21:
 
== Details ==
 
== Details ==
  
Bot does not "navigate" to the point. Instead, it walks straight to the specified point, hitting all obstacles on the way. If bot gets stuck for 2 seconds (for example, hitting the wall), the autopiloting ends.
+
Bot does not "navigate" to the point. Instead, it walks straight to the specified point, pushing into all obstacles on the way. Just like you keep pressing "arrow up" button on your keyboard.
 +
 
 +
If bot gets stuck for 2 seconds (for example, hitting the wall), the autopiloting ends.
  
 
You can use [[Bot_Playground/Commands/fly|fly]] command to start flying and reach the higher destination point.
 
You can use [[Bot_Playground/Commands/fly|fly]] command to start flying and reach the higher destination point.
Line 27: Line 29:
 
These events deliver the autopilot status:
 
These events deliver the autopilot status:
  
* [[Bot_Playground/Events/autopilot_completed|autopilot_started]] - autopilot started
+
* [[Bot_Playground/Events/autopilot_started|autopilot_started]] - autopilot started
 
* [[Bot_Playground/Events/autopilot_completed|autopilot_completed]] - autopilot reached destination point
 
* [[Bot_Playground/Events/autopilot_completed|autopilot_completed]] - autopilot reached destination point
* [[Bot_Playground/Events/autopilot_completed|autopilot_stuck]] - autopilot got stuck (and stopped)
+
* [[Bot_Playground/Events/autopilot_stuck|autopilot_stuck]] - autopilot got stuck (and stopped)
  
 
== Examples ==
 
== Examples ==
  
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
Bot.walkTo(128, 128, 20);
+
// Bots Playground script: [TEST] Autopilot events (build 1 by Glaznah Gassner)
 +
Bot.on("autopilot_completed", (event) => {
 +
console.log(`Autopilot completed: ${JSON.stringify(event, null, 2)}`);
 +
});
 +
 
 +
Bot.on("autopilot_stuck", (event) => {
 +
console.log(`Autopilot stuck: ${JSON.stringify(event, null, 2)}`);
 +
});
 +
 
 +
console.log("Script is running, waiting for autopilot events");
 +
 
 +
// Start autopilot
 +
Bot.walkTo(203, 37, 93);
 +
 
 +
// Gracefully end test script in 10 seconds
 +
setTimeout(() => process.exit(), 10_000);
 +
 
 +
/*
 +
clear
 +
07/12/2023 13:28:39
 +
Script is running, waiting for autopilot events
 +
 
 +
07/12/2023 13:28:42
 +
Autopilot completed: {
 +
  "name": "autopilot_completed",
 +
  "bot_slname": "DakotahRaine Resident",
 +
  "bot_uuid": "4f6b8999-14a0-4f50-882d-a764ee913daa",
 +
  "endPoint": {
 +
    "X": 203,
 +
    "Y": 37,
 +
    "Z": 93
 +
  },
 +
  "actualPoint": {
 +
    "X": 203.21898,
 +
    "Y": 36.799942,
 +
    "Z": 93
 +
  }
 +
}
 +
*/
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
{{NavMenu}}
 
{{NavMenu}}
 
__NOTOC__
 
__NOTOC__

Latest revision as of 10:32, 7 December 2023

Walk to a position within the current region.

Bot.walkTo(x, y, z);

Reference

This command accepts the following parameters:

Variable Required Description


Input:
x yes The X coordinate of the destination point
y yes The Y coordinate of the destination point
z yes The Z coordinate of the destination point
Output:
Function returns a Promise with the following data:
success bool true if command completed successfully
error string error string if command has failed

Details

Bot does not "navigate" to the point. Instead, it walks straight to the specified point, pushing into all obstacles on the way. Just like you keep pressing "arrow up" button on your keyboard.

If bot gets stuck for 2 seconds (for example, hitting the wall), the autopiloting ends.

You can use fly command to start flying and reach the higher destination point.

These events deliver the autopilot status:

Examples

// Bots Playground script: [TEST] Autopilot events (build 1 by Glaznah Gassner)
Bot.on("autopilot_completed", (event) => {
	console.log(`Autopilot completed: ${JSON.stringify(event, null, 2)}`);
});

Bot.on("autopilot_stuck", (event) => {
	console.log(`Autopilot stuck: ${JSON.stringify(event, null, 2)}`);
});

console.log("Script is running, waiting for autopilot events");

// Start autopilot
Bot.walkTo(203, 37, 93);

// Gracefully end test script in 10 seconds
setTimeout(() => process.exit(), 10_000);

/*
clear
07/12/2023 13:28:39
Script is running, waiting for autopilot events

07/12/2023 13:28:42
Autopilot completed: {
  "name": "autopilot_completed",
  "bot_slname": "DakotahRaine Resident",
  "bot_uuid": "4f6b8999-14a0-4f50-882d-a764ee913daa",
  "endPoint": {
    "X": 203,
    "Y": 37,
    "Z": 93
  },
  "actualPoint": {
    "X": 203.21898,
    "Y": 36.799942,
    "Z": 93
  }
}
*/