<?xml version="1.0" encoding="utf-8"?>
<s1 title="BuildingFunctions"><p><p>Contents</p>
<ol><li>
<link anchor="g">getBuildingLevel</link></li>
<li>
<link anchor="g-1">getBuildingByTypeId</link></li>
<li>
<link anchor="g-2">getBuildingByPosId</link></li>
<li>
<link anchor="c">countBuilding</link></li>
<li>
<link anchor="h">hasBuilding</link></li>
<li>
<link anchor="g-3">getTownHallLevel</link></li>
<li>
<link anchor="g-4">getWallLevel</link></li>
</ol>
</li>
</ol>
<p> </p>
<p>See also: <jump href="/wiki/Building">Building Objects</jump><br/>
 See also: <jump href="/wiki/BuildingTypes">Building Types</jump> </p>
<p></p>
<s2 id="getBuildingLevel" title="getBuildingLevel">
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.getBuildingLevel(BuildingType) </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>level = city.getBuildingLevel(23) </p>
</td></tr></table><p>This example finds the level of the Market (typeID = 23). </p>
<ul><li><source><![CDATA[echo city.getBuildingLevel(23)]]></source></li>
</ul>
<p>This example cancels all trades if the number of trades is equal to the level of the Market (typeID = 23). </p>
<ul><li><source><![CDATA[if city.tradesArray.length == city.getBuildingLevel(23) canceltrade]]></source></li>
</ul>
<p></p>
</s2>
<s2 id="getBuildingByTypeId" title="getBuildingByTypeId">
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.getBuildingByTypeId(BuildingType) </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.getBuildingByTypeId(23) </p>
</td></tr></table><p>This function returns an object for the building with the highest level of that typeId.  For example, to find your highest level barrack (typeID = 2): </p>
<ul><li><source><![CDATA[echo city.getBuildingByTypeId(2).level]]></source></li>
</ul>
<p>Valid parameters for this object are <em>level, name, positionId, startTime, endTime, typeId</em>, and <em>status</em>.  For example you can echo city.getBuildingByTypeId(2).name or city.getBuildingByTypeId(2).status. </p>
<p></p>
</s2>
<s2 id="getBuildingByPosId" title="getBuildingByPosId">
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.getBuildingByPosId(pos) </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.getBuildingByPosId(2) </p>
</td></tr></table><p>This example finds the name of the building at position 2: </p>
<ul><li><source><![CDATA[echo city.getBuildingByPosId(2).name]]></source></li>
</ul>
<p>You can find the positions with this: </p>
<p>[Image:http://i47.tinypic.com/21c5gro.jpg]</img> [Image:http://i.imgur.com/r1Voz7t.png]</img> </p>
<p></p>
</s2>
<s2 id="countBuilding" title="countBuilding">
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.countBuilding(BuildingType[,MinLevel[,MaxLevel]]) </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>totalmines = city.countBuilding(6,1,10) </p>
</td></tr></table><p>This example gives the total count of all iron mines (typeID = 6) between level 1 and 10: </p>
<ul><li><source><![CDATA[totalmines = city.countBuilding(6,1,10)]]></source></li>
</ul>
<p>This example will check if you have at least 3 sawmills (typeID = 4) at level 5 or higher: </p>
<ul><li><source><![CDATA[if city.countBuilding(4,5,10) >= 3 echo "I have at least 3 level 5+ sawmills."]]></source></li>
</ul>
<p>The MinLevel and MaxLevel parameters in countBuilding are optional. If you do not specify a minimum level, it defaults to level 1. If you do not specify a maximum level, it defaults to level 10. </p>
<p></p>
</s2>
<s2 id="hasBuilding" title="hasBuilding">
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.hasBuilding(typeId[,!Minlevel]) </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.hasBuilding(2,10) </p>
</td></tr></table><p>This function allows you to check if you have a building of a certain typeId of at least a specified level. The MinLevel is optional. If you do not specify a minimum level, it defaults to level 1. </p>
<p>In the example above, the check would return true if the city had a level 10 barrack in it. </p>
<p></p>
</s2>
<s2 id="getTownHallLevel" title="getTownHallLevel">
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.getTownHallLevel() </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>echo city.getTownHallLevel() </p>
</td></tr></table><p>This function returns the level of the townhall in the city. </p>
<p></p>
</s2>
<s2 id="getWallLevel" title="getWallLevel">
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>city.getWallLevel() </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>echo city.getWallLevel() </p>
</td></tr></table><p>This function returns the level of the wall in the city. </p>
<p></p>

<br/>------------------------------------------------------------------------------<br/>
<p> <jump href="/wiki/CategoryFunctions">CategoryFunctions</jump> </p>
</s2></s1>