Modifying TravelConnector/List Appending

I want to disallow travel if the PC isn’t wearing their outfit. This works:

[code]modify TravelConnector

canTravelerPass(traveler)
{
    if (adventurersOutfit.wornBy == me) return true; else return nil;
}

explainTravelBarrier(travel)
{
    "You're not going anywhere naked.  ";        
}

;
[/code]

Although the above works, I would like to implement it this way:

[code]nakedBarrier: TravelBarrier
canTravelerPass(traveler) { return adventurersOutfit.isWornBy(traveler); }
explainTravelBarrier(traveler)
{
"You’re not going anywhere naked. ";
}
;

modify TravelConnector
travelBarrier += nakedBarrier
;[/code]

This doesn’t work, however, because I can’t seem to append to a list with the += operator. I have tried…

travelBarrier.append(nakedBarrier)

…but this doesn’t work either. (I’m getting stack overflow in the library). Am I on the right track here? What’s the proper way to append to a list?

“travelBarrier += nakedBarrier” and “travelBarrier.append(nakedBarrier)” would work if you were using them within a function or method, but since you’re initialising a property, you have to do things a little differently.

This works:

modify TravelConnector travelBarrier = static inherited + nakedBarrier ;
The “static” tells TADS that this is just initialising the property, so it can add nakedBarrier at compile time and not worry about it again.

If, for some reason, you wanted TADS to recalculate the list every time it was used, you could do this instead:

modify TravelConnector travelBarrier = (inherited + nakedBarrier) ;
The parentheses are a shortcut for a function that just returns “inherited + nakedBarrier”.

Thanks, Emerald. I’m sure this must be written somewhere in the docs, I just haven’t managed to wander into that part of the wilderness yet (Systems Manual, perhaps?).