getLocation
Returns the current location of the bot.
await Bot.getLocation();Input
This function does not require any arguments.
Output
Function returns a Promise with the following data:
Variable | Type | Description |
|---|---|---|
| bool | True if command completed successfully |
| string | Error string if command has failed |
| boolean | Bot online flag |
| string | Bot region name |
| object | Current bot position (rounded to integer) |
| object | Exact bot position (with decimals) |
Example of position:
{
"x": 100,
"y": 110,
"z": 20
}Example of exactPosition:
{
"x": 100.01,
"y": 109.65,
"z": 20.4
}Details
This command returns the bot's position in real time. Use it to track the actual position of the bot.
The
Bot.status()command also returns the location, but the data may be cached for up to 30 seconds.The
positionfield is a rounded version ofexactPosition, added for convenience to avoid manual rounding.
Calling when offline
If getLocation() is called when the bot is offline:
onlinewill befalseregionwill be an empty stringAll coordinates (
x,y,z) will benull
Examples
const loc = await Bot.getLocation();
if (loc.region == "DuoLife") {
console.log("Wow, I'm in SmartBots region now!");
console.log(loc);
}Example output
{
"online": true,
"region": "DuoLife",
"position": {
"x": 230,
"y": 78,
"z": 32
},
"exactPosition": {
"x": 229.6,
"y": 77.69,
"z": 32.1
}
}