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

34 lines
1.5 KiB
Plaintext

\b;Instruction \c;turn\n;
Use the instruction \c;turn();\n; to instruct the bot to perform a rotation on itself of a certain number of degrees.
\b;Basic use
90 degreed means a quarter turn, 180 degrees means a half turn. A positive angle will perform a counterclockwise rotation, a negative angle means a clockwise rotation. Here are some examples with \c;turn();\n;:
\c;turn(90);\n; quarter turn to the left
\c;turn(-90);\n; quarter turn to the right (negative angle)
\c;turn(180);\n; half turn
In order to turn the bot towards an object found with the instruction \c;\l;radar\u cbot\radar;();\n;, you must calculate the rotation angle with the instruction \c;\l;direction\u cbot\direct;()\n;:
\c;
\s; item = \l;radar\u cbot\radar;(AlienSpider);
\s; turn(\l;direction\u cbot\direct;(item.position));
\n;
After these lines, just fire the cannon, and there is one hostile element less.
\b;For specialists
Syntax:
\s;\c;turn ( angle );\n;
Turns the bot with a given angle, right or left, without moving either forward or backward.
\t;angle: \c;\l;float\u cbot\float;\n;
Angle of the required rotation, in degrees. A positive value turns left, a negative value turns right. \c;turn(180)\n; turns round completely.
\t;Return value: \c;\l;int\u cbot\int;\n;
Zero if everything is OK, or a value different from zero if an error occurred.
\c;== 0 \n;rotation performed
\c;!= 0 \n;rotation impossible
\t;See also
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.