Variable lists do not seem to work


  • Admin

    I am working on my XML and stumbled into this problem. Is deliberate that this works:

        <attachment name="unitAttachment" attachTo="Frost-Trap" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
            <option name="isInfrastructure" value="true"/>
            <option name="givesMovement" value="-1:Footmen"/>
            <option name="givesMovement" value="-1:Cavalry"/>
            <option name="destroyedWhenCapturedBy" value="Gnomes"/>
        </attachment>
    

    But this does not work and will not let my load the XML: (and yes I made the variable list)

        <attachment name="unitAttachment" attachTo="Frost-Trap" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
            <option name="isInfrastructure" value="true"/>
            <option name="givesMovement" value="-1:$AllLandUnits$"/>
            <option name="givesMovement" value="-1:$AllAirUnits$"/>
            <option name="destroyedWhenCapturedFrom" value="@AllPlayers@"/>
        </attachment>
    

    If this is supposed to not work, I will have to make Looong value lists in this unit attackment 😞 Or am I doing something else wrong?
    BTW: I use very latest pre-release


  • Admin

    @Frostion At a glance, you need to use "$" not "@" if you want the whole list of players so like this:

        <attachment name="unitAttachment" attachTo="Frost-Trap" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
            <option name="isInfrastructure" value="true"/>
            <option name="givesMovement" value="-1:$AllLandUnits$"/>
            <option name="givesMovement" value="-1:$AllAirUnits$"/>
            <option name="destroyedWhenCapturedFrom" value="$AllPlayers$"/>
        </attachment>
    

  • Admin

    @redrum I still get an error:
    Unavngivet.png

    The AllLandUnits and AllAirUnits are used many times in the XML so it cant be them I think.


  • Admin

    @Frostion Can you post the 3 variable lists from the XML? Or just post your XML?


  • Admin


  • Admin

    @Frostion Oh the problem is the givesMovement doesn't allow a list of units. So you can't have this:

            <option name="givesMovement" value="-1:unit1:unit2:unit3"/>
    

    You have to do this:

            <option name="givesMovement" value="-1:unit1"/>
            <option name="givesMovement" value="-1:unit2"/>
            <option name="givesMovement" value="-1:unit3"/>
    

    So you can't use the variable list for those currently. Would be a good feature request to allow a list of units in a single line so the first example above would work 🙂


  • Admin


  • Donators

    @redrum, @Frostion
    Isn't 'givesMovement' an array list, and needs '-reset-'? So would something like this work:

        <attachment foreach="$AllLandUnits$^$AllAirUnits$" name="unitAttachment" attachTo="Frost-Trap" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
            <option name="isInfrastructure" value="true"/>
            <option name="givesMovement" value="-1:@AllLandUnits@"/>
            <option name="givesMovement" value="-1:@AllAirUnits@"/>
            <option name="destroyedWhenCapturedFrom" value="$AllPlayers$"/>
        </attachment>
    

    Cheers...


  • Admin

    @wc_sumpton I don't believe so. The foreach would be creating multiple separate unit attachments not multiple options in the same attachment.


  • Donators

    @redrum Yea caught that after I'd posted it (Watching American football). I believe that with a trigger this same thing could be achieved.

    Cheers...


  • Admin

    @wc_sumpton Yeah, I think you could do it with variable list + a trigger using it to essentially generate triggers to add to the unit attachment givesMovement list. But that is kind of messy for defining the unit attachment that isn't changing so decided it was worth updating the property to allow a list of unit types 🙂


Log in to reply
 

27480
1435
1666
Who's Online
Visitors Today