<?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>If</title><revhistory><revision><revnumber>5</revnumber><date>2012-12-04 22:02:34</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>4</revnumber><date>2012-12-04 22:02:17</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>3</revnumber><date>2012-12-04 21:53:39</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>2</revnumber><date>2012-12-04 21:53:01</date><authorinitials>Inanna</authorinitials></revision><revision><revnumber>1</revnumber><date>2012-12-04 21:52:49</date><authorinitials>Inanna</authorinitials></revision></revhistory></articleinfo><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>if (this condition is met) do this stuff </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>if (city.troop.archer &lt; 20k) train a:5k BigDude </para></entry></row></tbody></tgroup></informaltable><para>Just like the <ulink url="http://guide.neatportal.com/wiki/If/wiki/IfGoto#">IfGoto</ulink> and <ulink url="http://guide.neatportal.com/wiki/If/wiki/IfGosub#">IfGosub</ulink> commands, this will check if some condition is met first. Unlike those scripts however, it doesn't need to jump to a label elsewhere to perform an action based on the condition, it can instead perform it right there on the line. This allows you much more power and flexibility to create your scripts. </para><para>In the example above, if the city has less than 20k archers, then it will train 5k archers with the hero BigDude and carry on to the next line (if one exists).  </para><para>If can also use goto/gosub jumps to labels in it, for example: </para><itemizedlist><listitem override="none"><screen><![CDATA[if (city.troop.archer < 20k) gosub trainarchers
sleep 300
loop
]]><![CDATA[
label trainarchers
train a:5k BigDude
gosubreturn]]></screen></listitem></itemizedlist><para>While we do not yet support &amp;&amp; and || operations in Ifs, you can check for more than one condition to be met with nested Ifs, for example: </para><itemizedlist><listitem override="none"><screen><![CDATA[if (a == 1) if (b == 1) echo "Both a and b are equal to 1"]]></screen></listitem></itemizedlist><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="http://guide.neatportal.com/wiki/If/wiki/ScriptControlStructures#">ScriptControlStructures</ulink> </para></article>