<?xml version="1.0" encoding="utf-8"?>
<s1 title="Loop"><table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>loop [optional # of times]<br/>
loop [optional label]<br/>
loop [optional # of times] [optional label] </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>loop<br/>
loop 5<br/>
loop upgrade<br/>
loop 2 upgrade </p>
</td></tr></table><p>Allows you to repeat your entire script, or using a label repeat parts of a script. No parameter, or a parameter of 0 (ie - loop 0), will repeat the script indefinitely. </p>
<ul><li><source><![CDATA[//===============================
// Upgrade everything in your
// city, as long as tech and
// resource requirements are met
//===============================
      upgrade
      loop

//===============================
// Upgrade your farms, sawmills
// and your ironmines, then
// repeat the process again
// 5 times
//===============================
      upgrade farm
      upgrade saw
      upgrade iron
      loop 5

//===============================
// Upgrade your farms, sawmills
// and your ironmines, then
// upgrade cottages and repeat the cottages again
// 5 times
//===============================
      upgrade farm
      upgrade saw
      upgrade iron
      label cotupgrade
      upgrade cottage
      loop 5 cotupgrade]]></source></li>
</ul>
<p></p>

<br/>------------------------------------------------------------------------------<br/>
<p> </p>

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