<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>BuildingFunctions</title><revhistory><revision><revnumber>13</revnumber><date>2016-02-01 18:02:03</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>12</revnumber><date>2015-06-25 04:38:18</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>11</revnumber><date>2015-06-25 04:37:46</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>10</revnumber><date>2015-06-25 04:37:17</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>9</revnumber><date>2015-01-02 22:29:10</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>8</revnumber><date>2014-11-25 05:07:06</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>7</revnumber><date>2014-11-23 22:50:43</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>6</revnumber><date>2014-11-23 22:02:37</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>5</revnumber><date>2014-11-23 21:55:03</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>4</revnumber><date>2014-11-23 21:53:48</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>3</revnumber><date>2014-11-23 21:53:13</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>2</revnumber><date>2014-11-23 21:52:56</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>1</revnumber><date>2014-11-23 21:52:32</date><authorinitials>Inanna</authorinitials></revision></revhistory></articleinfo><para>See also: <ulink url="http://guide.neatportal.com/wiki/BuildingFunctions/wiki/Building#">Building Objects</ulink></para><para> See also: <ulink url="http://guide.neatportal.com/wiki/BuildingFunctions/wiki/BuildingTypes#">Building Types</ulink> </para><section><title>getBuildingLevel</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>city.getBuildingLevel(BuildingType) </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>level = city.getBuildingLevel(23) </para></entry></row></tbody></tgroup></informaltable><para>This example finds the level of the Market (typeID = 23). </para><itemizedlist><listitem override="none"><screen><![CDATA[echo city.getBuildingLevel(23)]]></screen></listitem></itemizedlist><para>This example cancels all trades if the number of trades is equal to the level of the Market (typeID = 23). </para><itemizedlist><listitem override="none"><screen><![CDATA[if city.tradesArray.length == city.getBuildingLevel(23) canceltrade]]></screen></listitem></itemizedlist></section><section><title>getBuildingByTypeId</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>city.getBuildingByTypeId(BuildingType) </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>city.getBuildingByTypeId(23) </para></entry></row></tbody></tgroup></informaltable><para>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): </para><itemizedlist><listitem override="none"><screen><![CDATA[echo city.getBuildingByTypeId(2).level]]></screen></listitem></itemizedlist><para>Valid parameters for this object are <emphasis>level, name, positionId, startTime, endTime, typeId</emphasis>, and <emphasis>status</emphasis>.  For example you can echo city.getBuildingByTypeId(2).name or city.getBuildingByTypeId(2).status. </para></section><section><title>getBuildingByPosId</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>city.getBuildingByPosId(pos) </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>city.getBuildingByPosId(2) </para></entry></row></tbody></tgroup></informaltable><para>This example finds the name of the building at position 2: </para><itemizedlist><listitem override="none"><screen><![CDATA[echo city.getBuildingByPosId(2).name]]></screen></listitem></itemizedlist><para>You can find the positions with this: </para><para><inlinemediaobject><imageobject><imagedata fileref="http://i47.tinypic.com/21c5gro.jpg"/></imageobject><textobject><phrase>http://i47.tinypic.com/21c5gro.jpg</phrase></textobject></inlinemediaobject> <inlinemediaobject><imageobject><imagedata fileref="http://i.imgur.com/r1Voz7t.png"/></imageobject><textobject><phrase>http://i.imgur.com/r1Voz7t.png</phrase></textobject></inlinemediaobject> </para></section><section><title>countBuilding</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>city.countBuilding(BuildingType[,MinLevel[,MaxLevel]]) </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>totalmines = city.countBuilding(6,1,10) </para></entry></row></tbody></tgroup></informaltable><para>This example gives the total count of all iron mines (typeID = 6) between level 1 and 10: </para><itemizedlist><listitem override="none"><screen><![CDATA[totalmines = city.countBuilding(6,1,10)]]></screen></listitem></itemizedlist><para>This example will check if you have at least 3 sawmills (typeID = 4) at level 5 or higher: </para><itemizedlist><listitem override="none"><screen><![CDATA[if city.countBuilding(4,5,10) >= 3 echo "I have at least 3 level 5+ sawmills."]]></screen></listitem></itemizedlist><para>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. </para></section><section><title>hasBuilding</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>city.hasBuilding(typeId[,!Minlevel]) </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>city.hasBuilding(2,10) </para></entry></row></tbody></tgroup></informaltable><para>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. </para><para>In the example above, the check would return true if the city had a level 10 barrack in it. </para></section><section><title>getTownHallLevel</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>city.getTownHallLevel() </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>echo city.getTownHallLevel() </para></entry></row></tbody></tgroup></informaltable><para>This function returns the level of the townhall in the city. </para></section><section><title>getWallLevel</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>city.getWallLevel() </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>echo city.getWallLevel() </para></entry></row></tbody></tgroup></informaltable><para>This function returns the level of the wall in the city. </para><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="http://guide.neatportal.com/wiki/BuildingFunctions/wiki/CategoryFunctions#">CategoryFunctions</ulink> </para></section></article>