colobot-data/help/D/cbot/motor.txt

40 lines
1.9 KiB
Plaintext
Raw Normal View History

\b;Instruction \c;motor\n;
The instruction \c;motor( , );\n; sets the speed for the left-hand and the right-hand motor of the bot.
\b;Basic use
The speed given to the motors will remain constant during the execution of the following instructions. Thanks to this characteristic it is possible to perform a rotation during the instruction \c;\l;fire\u cbot\fire;();\n;. This will sweep a whole zone with only one burst. Here is an example that will sweep the zone in front of the bot:
\c;
\s; \l;turn\u cbot\turn;(45); // turns 45 degrees left
\s; motor(0.5, -0.5); // slow rotation to the right
\s; \l;fire\u cbot\fire;(2); // fire
\s; motor(0,0); // stops the rotation
\n;
With the left-hand motor turning half-speed forward and the right-hand motor turning half-speed backward, the bot will turn slowly on itself during the 2-second-burst.
\b;For specialists
Syntax :
\s;\c;motor ( left, right );\n;
Gives speed instructions to the right and left motors of the robot. The motors will keep this speed until a new motor instruction is performed, or until a \c;\l;move\u cbot\move;\n;, \c;\l;turn\u cbot\turn;\n; or \c;\l;goto\u cbot\goto;\n; instruction is performed.
\t;left: \c;\l;float\u cbot\float;\n;
Speed instruction for the left motor; the value must range between -1 and 1.
\t;right: \c;\l;float\u cbot\float;\n;
Speed instruction for the right motor; the value must range between -1 and 1.
Examples :
\c;motor(1, 1);\n; moves forward with highest possible speed.
\c;motor(-0.5, -0.5);\n; moves backward with half speed.
\c;motor(1, -1);\n; turns right as fast as possible.
Note :
\c;motor(2, 2);\n; will not move forward any faster than \c;motor(1, 1)\n;
\c;motor(-2, -2);\n; will not move backward any faster than \c;motor(-1, -1)\n;
\t;Return value: \c;\l;void\u cbot\void;\n;
None.
\t;See also
\l;Instructions\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.