Colobot Wiki
Advertisement

With the instruction radar(), you can look for objects like enemies, bots, buildings or raw materials.

Basic use[]

Write in brackets the name of the object that you look for. Put the result in a variable of the type object. Here is an example that looks for the closest ant:

// At the beginning of the program:
object item; //variable declaration

//Look for the closest ant
item = radar(AlienAnt);

Syntax:[]

Radar1

Radar

radar(int category, float angle, float focus, float min, float max, float way);

Seen from above, the purple zone corresponds to the zone where objects will be detected. 

Category of the objects that should be detected. For example, when you are looking for an ant, write radar(AlienAnt);

way: (default value 1)

Determines which way the objects are detected. With value 1, returns the closest object found in the specified zone. With value -1, the farthest object in the zone will be returned.

Return value:[]

Returns the first object found that corresponds to the specified category in the specified zone. If no object was found, returns the value null.

Remark[]

You do not have to give all the parameters. Here are two examples of instructions that are equivalent: 

radar(Titanium, 0, 360, 0, 1000);
radar(Titanium); // equivalent

radar(Titanium, 0, 90, 0, 1000);
radar(Titanium, 0, 90); //equivalent

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: ex. radar (AlienAnt); detects the closest ant, wherever it may be. 

See also[]

Programming types and categories .

Advertisement