<?xml version="1.0" encoding="utf-8"?>
<s1 title="If"><table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>if (this condition is met) do this stuff </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>if (city.troop.archer &lt; 20k) train a:5k BigDude </p>
</td></tr></table><p>Just like the <jump href="/wiki/IfGoto">IfGoto</jump> and <jump href="/wiki/IfGosub">IfGosub</jump> commands, this will check if some condition is met first. Unlike those scripts however, it doesn&apos;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. </p>
<p>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).  </p>
<p>If can also use goto/gosub jumps to labels in it, for example: </p>
<ul><li><source><![CDATA[if (city.troop.archer < 20k) gosub trainarchers
sleep 300
loop

label trainarchers
train a:5k BigDude
gosubreturn]]></source></li>
</ul>
<p>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: </p>
<ul><li><source><![CDATA[if (a == 1) if (b == 1) echo "Both a and b are equal to 1"]]></source></li>
</ul>
<p></p>

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