Fandom

Colobot Wiki

Search

67pages on
this wiki
Add New Page
Comments0 Share

Syntax:Edit

object search(int category);

object search(int category, point center);

object search(int category, float x, float y );

Description:Edit

Search functions similarly to radar, but can be centered on locations other than the current bot. When no location argument is given, the search is centered on the executing bot, so:

search( PowerCell );

is equivalent to:

radar( PowerCell );

Return Value:Edit

Returns a reference to the object of the specified category nearest to the specified location, or null if no such object exists.

Example:Edit

object conv, cube;

conv = radar( Converter );
if( conv != null )
{
    cube = search(Titanium, conv.position.x, conv.position.y);
    if( cube == null or distance( cube.position, conv.position ) > 2 )
    {
        //There is no Titanium in the converter, go find some
        loadTitanium();
    }
}


The above example checks for Titanium at the nearest Converter and calls another function "loadTitanium()" if the Converter is empty (n.b. To be useful, the function should also check for TitaniumOre).

See also.Edit

CBOT Language Radar

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.