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

From SmartBots Developers Docs
Jump to: navigation, search
(Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} <onlyinclude>Returns current location of the bot bot.</onlyinclude> <syntaxhighlight lang="javascript"> const res = await Bot.getLocation();...")
 
Line 16: Line 16:
 
{{API Variable|online|boolean}} Bot online flag
 
{{API Variable|online|boolean}} Bot online flag
 
{{API Variable|region|string}} Bot region name
 
{{API Variable|region|string}} Bot region name
{{API Variable|position|object}} Current bot position, rounded
+
{{API Variable|position|object}} Current bot position, rounded to integer:
{{API Variable|exactPosition|object}} Exact bot position (with decimals)
+
<syntaxhighlight lang="json">
 +
{
 +
  x: number;
 +
  y: number;
 +
  z: number;
 +
}
 +
{{API Variable|exactPosition|object}} Exact bot position (the same as 'position' but with decimals)
  
 
{{API Variables Table End}}
 
{{API Variables Table End}}

Revision as of 08:37, 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;
  y: number;
  z: number;
}
{{API Variable|exactPosition|object}} Exact bot position (the same as 'position' but with decimals)

{{API Variables Table End}}

== Details ==

Command returns bot position, mostly in real-time. Use this command to track actual bot position.

Note: [[status|status()]] command also returns 'location' but it may be cached for up to 30 seconds.

== Examples ==

<syntaxhighlight lang="javascript">
const loc = await Bot.getLocation();
if(loc.region == "DuoLife") {
  console.log("Wow, I'm in SmartBots region now!");
}