colobot-data/help/cbot/E/goto.txt

36 lines
2.1 KiB
Plaintext

\b;Instruction \c;goto\n;
The instruction \c;goto();\n; instructs the bot to reach a given position.
\b;Basic use
The most current use consists in moving the bot to an object located with the instruction \c;\l;radar\u cbot\radar;();\n;. If the information returned by the \c;\l;radar\u cbot\radar;();\n; has been stored in a certain variable, write the name of the variable followed by \c;.position\n; in order to get the position of the object. Here is an example of a program that looks for a \l;titanium cube\u object\titan;, goes to the position and grabs it:
\c;
\s; item = \l;radar\u cbot\radar;(Titanium);
\s; goto(item.position);
\s; \l;grab\u cbot\grab;();
\n;
\b;For specialists
Syntax:
\s;\c;goto ( position, altitude, goal, crash );\n;
Tells the robot to go to the given position, avoiding all the obstacles if this is possible.
\t;pos: \c;\l;point\u cbot\point;\n;
Coordinates of the goal position.
\t;altitude: \c;\l;float\u cbot\float;\n;
Flight altitude for \l;winged bots\u object\botgj;. The altitude is useful only for \l;winged bots\u object\botgj;. From the initial altitude, the bot climbs higher until it reaches the specified hight. When arriving close to destination, it goes down to touch the ground at the given position. If no value is given, an altitude of 10 meters is the default value. On very short moves, even winged bot stay on the ground. For all bot except winged bots, this parameter is ignored.
\t;goal: \c;\l;int\u cbot\int;\n; (default value \c;0\n;)
This parameter tells the bot how it must reach the goal:
\c;0\n; stops exactly at the goal position
\c;1\n; goes close to the goal position, without stopping.
If no value is given, \c;1\n; (precision) is the default value.
\t;Return value: \c;\l;int\u cbot\int;\n;
Normally an error stops the program. You can prevent the program from stopping on errors by using the \c;\l;errmode\u cbot\errmode;(0)\n; instruction. A value different from zero if an error occurred is then returned by \c;goto()\n;.
\c;== 0 \n;Goal position reached
\c;!= 0 \n;Goal position impossible to reach
\t;See also
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.