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;.
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;.