Difference between revisions of "Bot Playground/Events/self position"

From SmartBots Developers Docs
Jump to: navigation, search
(Created page with "{{DISPLAYTITLE:self_position}} <onlyinclude>Fires when bot receives a changes his position.</onlyinclude> <syntaxhighlight lang="javascript"> Bot.on("self_position", function...")
 
Line 1: Line 1:
 
{{DISPLAYTITLE:self_position}}
 
{{DISPLAYTITLE:self_position}}
<onlyinclude>Fires when bot receives a changes his position.</onlyinclude>
+
<onlyinclude>Fires when bot receives a changes his position. {{NotAvailableForQB}}</onlyinclude>
  
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">

Revision as of 07:52, 12 October 2022

Fires when bot receives a changes his position. Not available for QubicBot yet (?)

Bot.on("self_position", function(event) { ... });

Reference

This event comes with the following event object:

Variable Required Description
event object properties:
name The name of the event in this case region_restart
region The name of the region the bot is at.
heading The direction in degrees where the bot is facing.
bot_uuid The UUID of the bot.
active_group The active group uuid of the bot.
position The current position of the bot.

Position Format:

  • X
  • Y
  • Z

Comment

The event fires when bot's position and/or view direction changes. The view direction change threshold is 5 degrees (thus, you won't get a notification if bot turns for less than 5 degrees).

The event is usually sent real time but can be postponed to avoid flooding your script with self_position event.


Example

console.log(`${process.name} started`);

Bot.on("self_position", (event) => {
    console.log(`self position event:`, event);
});