• 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

    Usage:

    if (this condition is met) do this stuff

    Example:

    if (city.troop.archer < 20k) train a:5k BigDude

    Just like the IfGoto and IfGosub commands, this will check if some condition is met first. Unlike those scripts however, it doesn'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.

    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).

    If can also use goto/gosub jumps to labels in it, for example:

    • if (city.troop.archer < 20k) gosub trainarchers
      sleep 300
      loop
      
      label trainarchers
      train a:5k BigDude
      gosubreturn

    While we do not yet support && and || operations in Ifs, you can check for more than one condition to be met with nested Ifs, for example:

    • if (a == 1) if (b == 1) echo "Both a and b are equal to 1"


    ScriptControlStructures

    If (last edited 2012-12-04 22:02:34 by Inanna)