Difference between revisions of "Bot Playground/Commands/getLocation"
From SmartBots Developers Docs
Line 19: | Line 19: | ||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json"> | ||
{ | { | ||
− | x: number; | + | x: number; // 100 |
− | y: number; | + | y: number; // 110 |
− | z: number; | + | z: number; // 20 |
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | {{API Variable|exactPosition|object}} Exact bot position (the same as 'position' but with decimals) | + | {{API Variable|exactPosition|object}} Exact bot position (the same as 'position' but with decimals): |
+ | <syntaxhighlight lang="json"> | ||
+ | { | ||
+ | x: number; // 100.01 | ||
+ | y: number; // 109.65 | ||
+ | z: number; // 20.4 | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
{{API Variables Table End}} | {{API Variables Table End}} |
Revision as of 08:39, 27 February 2025
Returns current location of the bot bot.
const res = await Bot.getLocation();
console.log("Bot location:", res);
Reference
This command accepts the following parameters:
Variable | Required | Description
| |
---|---|---|---|
Input: | |||
Output: | |||
Function returns a Promise with the following data: | |||
success | bool | true if command completed successfully | |
error | string | error string if command has failed | |
online | boolean | Bot online flag | |
region | string | Bot region name | |
position | object | Current bot position, rounded to integer:
{
x: number; // 100
y: number; // 110
z: number; // 20
}
| |
exactPosition | object | Exact bot position (the same as 'position' but with decimals):
{
x: number; // 100.01
y: number; // 109.65
z: number; // 20.4
}
|
Details
Command returns bot position, mostly in real-time. Use this command to track actual bot position.
Note: status() command also returns 'location' but it may be cached for up to 30 seconds.
Examples
const loc = await Bot.getLocation();
if(loc.region == "DuoLife") {
console.log("Wow, I'm in SmartBots region now!");
}