FindBuildings (Harvest)

From OxeyeWiki

Jump to: navigation, search

getNumBuildings()

Finds all buildings.

Parameter Expected Type Description
Returns

Returns an array of all buildings.

Harvest Library


getNumBuildings(type)

Finds all buildings of a certain type, such as "SPARKPRODUCER" (Solar Plants).

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

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

Harvest Library


getNumBuildings(x, y, radius)

Finds all buildings 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 buildings in an certain radius.

Harvest Library


getNumBuildings(x, y, radius, type)

Finds all buildings 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 buildings in an certain radius with a certain type.

Harvest Library


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

Finds all buildings 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 buildings in an certain rectangle with a certain type.

Harvest Library


Description

All of the functions above will return an array (which can be empty) of buildings. The buildings will be of user data lua type, and refer to a CBuildingLuaInfo 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 a building is destroyed. Instead, if you need to keep track of a specific building, you will have to save it's ID number and then locate it each frame with harvest.getBuilding(id).

Example

-- destroy all buildings in the circle!
buildings = harvest.findBuildings(x, y, 200)
for i=1,#buildings do
   local x,y = buildings[i]:getPosition()
   harvest.spawnParticle(buildings[i]:getDeathParticle(), x, y)
   buildings[i]:remove()
end

Resources

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox