Foreach loop not working

  • I anm receiving the following error

    Could not parse:file:///C:/Users/Roger/triplea/downloadedMaps/Experiment/AA50-41-Maintenance.xml, Attachment has invalid variables in foreach: $ActivePlayer$ Attachment has invalid variables in foreach: $ActivePlayer$

    Here is the code:

      <variable name="ActivePlayer">
        <element name="Germans"/>
        <element name="Russians"/>
        <element name="Japanese"/>
        <element name="Americans"/>
        <element name="British"/>
        <element name="Italians"/>


         <attachment foreach="$ActivePlayer$" name="objectiveAttachment@ActivePlayer@_Extra_Income" attachTo="@ActivePlayer@" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
          <option name="objectiveValue" value="1"/>
          <option name="directOwnershipTerritories" value="map" count="each"/>

    I have used foreach successfully before. Does anyone see the problem>

  • I forget to wrap the variable with variableList.

  • @RogerCooper Glad i could help! šŸ˜¹

  • @RogerCooper By the way, I made a simple tool that will generate variableLists from all territories and players and put that in your game file. It's the vars command from the CLI here:

Log in to reply