FindAliens (Harvest)

From OxeyeWiki

Jump to: navigation, search

findAliens()

Finds all aliens.

Parameter Expected Type Description
Returns

Returns an array of all aliens.

Harvest Library


findAliens(type)

Finds all aliens of a certain type, such as ALIEN_DEFAULT.

Parameter Expected Type Description
type String The building identifier name used for selection.
Returns

Returns an array of all aliens of a cretin identifier name.

Harvest Library


findAliens(x, y, radius)

Finds all aliens in a circle.

Parameter Expected Type Description
x Number The x coordinate of a point on the world map.
y Number The y coordinate of a point on the world map.
radius Number The radius to be used.
Returns

Returns an array of all aliens in an certain radius.

Harvest Library


findAliens(x, y, radius, type)

Finds all aliens of a certain type in a circle.

Parameter Expected Type Description
x Number The x coordinate of a point on the world map.
y Number The y coordinate of a point on the world map.
radius Number The radius to be used.
type String The building identifier name used for selection.
Returns

Returns an array of all aliens in an certain radius with a certain type.

Harvest Library


findAliens(left, top, right, bottom, type)

Finds all aliens of a certain type in a rectangle.

Parameter Expected Type Description
left Number The left coordinate of the rectangle.
top Number The top coordinate of the rectangle.
right Number The right coordinate of the rectangle.
bottom Number The bottom coordinate of the rectangle.
type String The building identifier name used for selection.
Returns

Returns an array of all aliens in an certain rectangle with a certain type.

Harvest Library


Description

Like with buildings, all of the functions above will return an array (which can be empty). The aliens will be of userdata lua type, and refer to a CAlienLuaInfo in Harvest's C++ code. On these objects you can perform getPosition(), getId() and various other functions (see separate thread soon). However, you may not keep a reference to these objects since it's not possible to predict when an alien has been removed. Instead, if you need to keep track of a specific alien, you will have to save it's ID number and then locate it each frame with harvest.getAlien(id).

Example

-- randomly displace all aliens
aliens = harvest.findAliens()
local left,top,right,bottom = harvest.getWorldBorders()
local width, height = right - left, bottom - top
for i=1,#aliens do
   aliens[i]:setPosition(left + math.random() * width, top + math.random() * height)
end

Resources

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox