||<tablebgcolor="#F9F9F9" tablestyle="margin:1em 1em 1em 0px;border-style:solid;border-color:rgb(170, 170, 170);color:rgb(0, 0, 0);font-family:sans-serif;font-size:13px;line-height:19.5px;text-align:start;  " tableclass="wikitable"#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;  ">Usage: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">gosub label ||
||<#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;  ">Example: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">gosub medalfarm ||


Allows you to jump to a subroutine, perform the actions there, and then  return to continue to the next scripted line.

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.

 . {{{
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
gosubreturn
}}}

Do not forget to add the GosubReturn at the end of each subroutine to avoid errors.

----
----
ScriptControlStructures