I’ve been playing around creating things and getting my head around how TADS works and methods for cutting down code. I’ve been trying to create a clothing class that won’t let you put two of the same type on, such as 2 hats or 2 pairs of shoes. I figured it out upto consilidating it down to one class ‘clothes’ rather than having ‘tops’, ‘pants’, ‘shoes’ etc and ended up with this where clothingType = gActor.wearingXXX
[spoiler][code]Clothes: Wearable
isListedInContents=(moved)
clothingType = nil
message = nil
dobjFor(Doff)
{
action()
{
clothingType = nil;
inherited;
}
}
dobjFor(Wear)
{
verify()
{
if(self.isWorn)
{ inherited; }
else if(clothingType)
{
illogicalAlready('You\'re already wearing <<message>>, you don\'t need to wear any more');
}
}
action()
{
clothingType = true;
inherited;
}
}
;[/code][/spoiler]
I know that where it calls (clothingType) it actually points where it should since testing for if(!clothingType) makes it impossible to wear anything. I’m just a bit stumped as to why it isn’t working the same as when it was with gActor.wearingXXX in its place. Can I do it this way or is there some sort of workaround (I thought about writing a method but so far every attempt to do that has resulted in the compiler screaming at me).
On a side note is it possible to have a description for just the first time something is seen and then a usuall description afterwards or is my best bet to just add <> at the end of the description?
Any help would be much appreciated
Kel