<?xml version="1.0" encoding="utf-8"?>
<s1 title="Gosub"><table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Usage: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>gosub label </p>
</td></tr><tr><td><strong class="highlight"><![CDATA[]]></strong><p>Example: </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p>gosub medalfarm </p>
</td></tr></table><p>Allows you to jump to a subroutine, perform the actions there, and then  return to continue to the next scripted line. </p>
<p>In the following example, the bot will read line 1, jump to label medalfarm, perform the attack there, return to the original place and read line 2, jump to label trainarch, queue up the archers, return to the original place and read line 3, jump to label upgradecot, upgrade the cottage twice, return to the original place and read line 4, sleep 30 seconds, and then loop back to line 1 where it will begin the process again with label medalfarm. </p>
<ul><li><source><![CDATA[gosub medalfarm
gosub trainarch
gosub upgradecot
sleep 30
loop 0

label medalfarm
attack 123,300 !Bubba,!Xavier,any t:400,b:400
return

label upgradecot
upgrade house
repeat 2
return

label trainarch
train arch:2500 Hero
return]]></source></li>
</ul>
<p>Do not forget to add the <jump href="/wiki/Return">Return</jump> at the end of each subroutine to avoid errors. </p>
<p></p>

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

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