• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (GUI)
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages


    ifgosub ( reference {operator} value ) label


    ifgosub ( m_city.cityManager.resource.stone.amount > 250000 ) CheckATT

    Like it's counterpart Gosub, IfGosub allows you to jump to a label subroutine elsewhere in the script, perform the actions there, and then return to where it left off in the current script. The difference is that this one allows you to check a conditional statement before deciding whether to jump to the subroutine or move on to the next line.

    Using References, this script command allows you powerful access to manage your account, cities, heroes, and armies with precision.

    In the following example, the bot will first check if your stone in the city is over 250k, and if so jump to label CheckATT. In label CheckATT the bot will further check if you have over 250k wood in the city, and if so jump to label UpATT. In label UpATT, the bot will build 250 archer towers and return to the label that called it (CheckATT). Once back in CheckATT it has nothing else to check or perform, so it returns back to the original start of the script and moves to the next line.

    This next line is going to check if your city has over 150k iron, and if so jump to label CheckTrain. Once in CheckTrain it will check if your city has over 150k wood, and if so jump to label TrainTroops. In label TrainTroops the bot will queue 250 archers with hero Bubba, 4 times, then return to label CheckTrain. With nothing more to do in CheckTrain, it will return back to your original script and move to the next line, which will tell the bot to sleep randomly from 0 to 3000 seconds and then loop back to line 1.

    If at any point in the script or any subroutine, one of the checks had failed then the bot would not jump to that subroutine, and would instead move to the next line. For example, if at the very first line you did not have 250k+ stone, the bot would have not jumped to label CheckATT but would instead have moved to line 2 and checked for 150k+ iron. If that failed also, then the bot would have slept until it was time to check again for resources.

    • ifgosub ( m_city.cityManager.resource.stone.amount > 250000 ) CheckATT
      ifgosub ( m_city.cityManager.resource.iron.amount > 150000 ) CheckTrain
      sleep rnd:3000
      loop 0
      label CheckTrain
      ifgosub ( m_city.cityManager.resource.wood.amount > 150000 ) TrainTroops
      label CheckATT
      ifgosub ( m_city.cityManager.resource.wood.amount > 250000 ) UpATT
      label TrainTroops
      train arch:250 Bubba
      repeat 4
      label UpATT
      walldefense archertowers 250

    As with Gosub, do not forget the Return at the end of each subroutine.

    ScriptControlStructures ScriptDeprecated

    IfGosub (last edited 2015-09-02 12:45:10 by Romulus)