Difference between revisions of "Bot Playground/Commands/move"
From SmartBots Developers Docs
(Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} <onlyinclude>Start or stop bot movement and rotations.</onlyinclude> <syntaxhighlight lang="javascript"> Bot.move(instruction, state); </synt...") |
|||
| Line 40: | Line 40: | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
| + | Bot.move("FORWARD", "START"); | ||
| + | |||
| + | // Walk forward for 2 seconds | ||
| + | await process.sleep(2_000); | ||
| + | |||
| + | Bot.move("FORWARD", "STOP"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{NavMenu}} | {{NavMenu}} | ||
__NOTOC__ | __NOTOC__ | ||
Latest revision as of 11:03, 7 December 2023
Start or stop bot movement and rotations.
Bot.move(instruction, state);
Reference
This command accepts the following parameters:
| Variable | Required | Description
| |
|---|---|---|---|
| Input: | |||
| instruction | yes | The movement instruction. One of the following:
| |
| state | yes | value which controls the "instruction" completion:
| |
| 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
This function allows establishing a direct control over bot's movement.
This function may be a bit laggy, and you might find Bot.walkTo() command to be more precise. However, use this command if you want a direct control over the bot's movement.
Related events:
- self_position event will deliver you the bot position while it changes
Examples
Bot.move("FORWARD", "START");
// Walk forward for 2 seconds
await process.sleep(2_000);
Bot.move("FORWARD", "STOP");