<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.oxeyegames.com/wiki/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.oxeyegames.com/wiki/index.php?action=history&amp;feed=atom&amp;title=FindBuildings_%28Harvest%29</id>
		<title>FindBuildings (Harvest) - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.oxeyegames.com/wiki/index.php?action=history&amp;feed=atom&amp;title=FindBuildings_%28Harvest%29"/>
		<link rel="alternate" type="text/html" href="http://www.oxeyegames.com/wiki/index.php?title=FindBuildings_(Harvest)&amp;action=history"/>
		<updated>2026-05-01T22:53:10Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.0</generator>

	<entry>
		<id>http://www.oxeyegames.com/wiki/index.php?title=FindBuildings_(Harvest)&amp;diff=255&amp;oldid=prev</id>
		<title>166 MMX: Created page with '{{HarvestMethod | getNumBuildings() | Finds all buildings. | | Returns an array of all buildings. }}  {{HarvestMethod | getNumBuildings(type) | Finds all buildings of a certain t...'</title>
		<link rel="alternate" type="text/html" href="http://www.oxeyegames.com/wiki/index.php?title=FindBuildings_(Harvest)&amp;diff=255&amp;oldid=prev"/>
				<updated>2009-12-02T20:02:29Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#39;{{HarvestMethod | getNumBuildings() | Finds all buildings. | | Returns an array of all buildings. }}  {{HarvestMethod | getNumBuildings(type) | Finds all buildings of a certain t...&amp;#39;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{HarvestMethod&lt;br /&gt;
|&lt;br /&gt;
getNumBuildings()&lt;br /&gt;
|&lt;br /&gt;
Finds all buildings.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
Returns an array of all buildings.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{HarvestMethod&lt;br /&gt;
|&lt;br /&gt;
getNumBuildings(type)&lt;br /&gt;
|&lt;br /&gt;
Finds all buildings of a certain type, such as &amp;quot;SPARKPRODUCER&amp;quot; (Solar Plants).&lt;br /&gt;
|&lt;br /&gt;
{{MethodParam|type|String|The building identifier name used for selection.}}&lt;br /&gt;
|&lt;br /&gt;
Returns an array of all buildings of a cretin identifier name.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{HarvestMethod&lt;br /&gt;
|&lt;br /&gt;
getNumBuildings(x, y, radius)&lt;br /&gt;
|&lt;br /&gt;
Finds all buildings in a circle.&lt;br /&gt;
|&lt;br /&gt;
{{MethodParam|x|Number|The x coordinate of a point on the world map.}}&lt;br /&gt;
{{MethodParam|y|Number|The y coordinate of a point on the world map.}}&lt;br /&gt;
{{MethodParam|radius|Number|The radius to be used.}}&lt;br /&gt;
|&lt;br /&gt;
Returns an array of all buildings in an certain radius.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{HarvestMethod&lt;br /&gt;
|&lt;br /&gt;
getNumBuildings(x, y, radius, type)&lt;br /&gt;
|&lt;br /&gt;
Finds all buildings of a certain type in a circle.&lt;br /&gt;
|&lt;br /&gt;
{{MethodParam|x|Number|The x coordinate of a point on the world map.}}&lt;br /&gt;
{{MethodParam|y|Number|The y coordinate of a point on the world map.}}&lt;br /&gt;
{{MethodParam|radius|Number|The radius to be used.}}&lt;br /&gt;
{{MethodParam|type|String|The building identifier name used for selection.}}&lt;br /&gt;
|&lt;br /&gt;
Returns an array of all buildings in an certain radius with a certain type.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{HarvestMethod&lt;br /&gt;
|&lt;br /&gt;
getNumBuildings(left, top, right, bottom, type)&lt;br /&gt;
|&lt;br /&gt;
Finds all buildings of a certain type in a rectangle.&lt;br /&gt;
|&lt;br /&gt;
{{MethodParam|left|Number|The left coordinate of the rectangle.}}&lt;br /&gt;
{{MethodParam|top|Number|The top coordinate of the rectangle.}}&lt;br /&gt;
{{MethodParam|right|Number|The right coordinate of the rectangle.}}&lt;br /&gt;
{{MethodParam|bottom|Number|The bottom coordinate of the rectangle.}}&lt;br /&gt;
{{MethodParam|type|String|The building identifier name used for selection.}}&lt;br /&gt;
|&lt;br /&gt;
Returns an array of all buildings in an certain rectangle with a certain type.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- destroy all buildings in the circle!&lt;br /&gt;
buildings = harvest.findBuildings(x, y, 200)&lt;br /&gt;
for i=1,#buildings do&lt;br /&gt;
   local x,y = buildings[i]:getPosition()&lt;br /&gt;
   harvest.spawnParticle(buildings[i]:getDeathParticle(), x, y)&lt;br /&gt;
   buildings[i]:remove()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Resources ===&lt;br /&gt;
*[http://www.oxeyegames.com/forum/viewtopic.php?p=1523#p1523 Oxeye Game Studio Forum - Harvest Functions]&lt;/div&gt;</summary>
		<author><name>166 MMX</name></author>	</entry>

	</feed>