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

61 lines
2.7 KiB
Plaintext

\b;Instruction \c;radar\n;
With the instruction \c;radar()\n;, you can look for objects like \l;enemies\u object\mother;, bots, buildings or raw materials.
\b;Basic use
Write in brackets the \l;name of the object\u cbot\category; that you look for. Put the result in a variable of the \l;type\u cbot\type; \c;object\n;. Here is an example that looks for the closest ant:
\c;
\s;// At the beginning of the program:
\s;object item; // variable declaration
\s;
\s;// Look for the closest ant
\s;item = radar(AlienAnt);
\n;
\b;For specialists
Syntax:
\s;\c;radar ( category, angle, focus, min, max, way );\n;
Detects an object according to several parameters.
\image radar1 8 8;
Seen from above, the purple zone corresponds to the zone where objects will be detected.
\t;category: \c;\l;int\u cbot\int;\n;
\l;Category\u cbot\category; of the objects that should be detected. For example, when you are looking for an ant, write \c;radar (AlienAnt)\n;.
\t;angle: \c;\l;float\u cbot\float;\n; (default value\c;0\n;)
Direction that the radar is facing, in degrees.
\c; 0\n; -> radar is facing straight ahead
\c;-90\n; -> radar is facing a quarter turn right
\c; 90\n; -> radar is facing a quarter turn left
\t;focus: \c;\l;float\u cbot\float;\n; (default value\c;360\n;)
Opening angle of the radar, in degrees.
\t;min: \c;\l;float\u cbot\float;\n; (default value \c;0\n;)
Minimum detection distance, in meters. Objects that are closer than the minimum distance will not be detected.
\t;max: \c;\l;float\u cbot\float;\n; (Default value\c;1000\n;)
Maximum detection distance, in meters. Objects that are farther away than the maximum distance will not be detected.
\t;way: \c;\l;float\u cbot\float;\n; (default value\c;1\n;)
Determines which way the objects are detected. With value \c;1\n;, returns the closest object found in the specified zone. With value \c;-1\n;, the farthest object in the zone will be returned.
\t;Return value: \c;\l;object\u cbot\object;\n;
Returns the first object found that corresponds to the specified category in the specified zone. If no object was found, returns the value \c;\l;null\u cbot\null;\n;.
\t;Remark
You do not have to give all the parameters. Here are two examples of instructions that are equivalent:
\c;
\s; radar(Titanium, 0, 360, 0, 1000);
\s; radar(Titanium); // equivalent
\s; radar(Titanium, 0, 90, 0, 1000);
\s; radar(Titanium, 0, 90); // equivalent
\n;
When one or more parameters are not specified, the default values indicated above are used instead; only the first parameter is compulsory.
Generally, only the first parameter is specified: f. ex. \c;radar (AlienAnt)\n; detects the closest ant, wherever it may be.
\t;See also
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.