Problems using CollectiveGroup

I thought I’d sorted all my parser troubles out but apparently not, I’m pretty sure I’m going to need a bit of a re-sort of my groups and add an extra decoration or something so I’m just after a bit of advice really.

What I’m after is something that will look like this

I get that having it as a collective group tries to wear all of the pairs of shoes (which is what’s happening) but oddly enough when I try ‘wear clothes’ I get my notWearableMsg (I don’t really want to wear all of my clothes) which is what I want. At the moment though I get this

I’m more than a little confused since it recognises the pile of shoes when you type “look at shoes” but not when you type look at “pile of shoes”, I’m more interested in making it not handle them collectively for wearing though, any ideas anyone?

I’ve never used a CollectiveGroup, but there’s a good discussion starting on p. 260 of “Learning TADS 3.” Have you studied that?

With respect to the “pile of shoes” problem, I believe the parser will sort this out if you make both ‘pile’ and ‘shoes’ nouns for the group (or object). It’s supposed to, anyway. That is, for vocabWords (presumably in the template):

'gorgeous fashionable shoes/pile'

I hadn’t read that, just the bits in the Tads 3 Tour Guide and the Library Reference Manual. According to what’s in Learning Tads 3 though it says only examine is handled collectively. On thinking about it I’m not 100% sure it is trying to handle it collectively since it doesn’t try to wear flip flops as well, just the things that have ‘shoes’ defined in their vocab, which I would have thought the parser would ask which we meant in that case…

I tried adding pile to the list of nouns as well with no luck, but thank you I hadn’t thought of that… On that note though I just found out that I had to add ‘of’ to the list to make it work :slight_smile:

EDIT> I’ve also tried changing the CollectiveGroup to decoration with the same result of trying to wear everything (this time including the pile of shoes) so the problem may not be with the group after all, in theory it should be asking me which shoes I want to wear, any reason why it might not?

Here’s one approach.

+ shoesGroup: CollectiveGroup, Fixture 'pile/shoes' 'pile of shoes'
	"It's where I kick my shoes when I come in, there's my sneakers, some high
	heels and probably some flip flops in there too. "

	// examine and take should redirect to pile, wear should disambiguate
	isCollectiveAction(action, whichObj) {
		if (action.ofKind(ExamineAction)
			|| action.ofKind(TakeAction))
			return true;
		return nil;
	}

	// if we're looking at shoes at all, we want to look at the pile
	isCollectiveQuant(np, requiredNum) {
		return true;
	}

	// show fixture in room contents
	isListed = true

	// should be "a pile of shoes" instead of "some pile of shoes"
	isPlural = nil
;

class Shoes: Wearable
	// objects will inherit this vocab word automatically
	vocabWords = 'shoes'

	// our pile of shoes
	collectiveGroups = [shoesGroup]

	// should only list shoes if they're held or away from the pile
	isListed () {
		return (self.isIn(gPlayerChar)
				|| (self.getOutermostRoom != shoesGroup.getOutermostRoom())
		);
	}

	isPlural = true
;

+ sneakers: Shoes 'sneakers' 'sneakers';
+ heels: Shoes 'heels' 'heels';
+ flipflops: Shoes 'flip flops' 'flip flops';

It took me awhile to find the isCollectiveQuant() method. By default the collectiveGroup only intercepts actions that don’t specify a certain quantity, and by giving each object a “shoes” vocab word, the parser decides that one specific pair must be wanted, and triggers disambiguation.

One issue is that the pile always claims to have the full set of footwear, even when the player is holding some or all of it. A possible solution would be to block the player from taking a pair if holding another one, and then vary the pile description based on which of the three (if any) was held.

I added that code in and tried having a play with it in but it didn’t change anything :frowning: was worth a shot though, and thanks for looking for me. I’d seen the methods though didn’t have a clue as to how I’d implement them. I’ve decided it not that it’s confusing the shoes with the pile of shoes, it’s simply trying to wear all the shoes at once rather than asking which I wan’t to wear. This is just as much a puzzler though

I’ve just tested it with the shoesGroup location set to nil and as a decoration to make sure it definately isn’t the group that’s affecting it so I know for sure that isn’t the case now.

As for the description of the pile I’d already thought about that, when I get around to it I was going to make the shoes go back to the pile and any other clothes just dropped so long as the player is in the bedroom rather than give it a dynamic description, I’ve been making enough of them for now :stuck_out_tongue:

The code I posted produces this output.

Apart from the text of the disambiguation message and the failure message, that seems to be what you’re after. What did I miss?

bcressey… You are a leg end!

It’s took some backtracking to get it to disambiguate everything (including the pile) and then adding back in (uncommenting ahem) the isCollectiveAction and isCollectiveQuant… Just wondering, because I wouldn’t have known how to use that let alone to use it, am I right in thinking that the isCollectiveAction tells us which actions to allow collectively and then isCollectiveQuant is used so that if no number is given (ie. ‘look at the pens’ instead of ‘look at the 3 pens’) that it handles them collectively, I just checked it and it works how I want it to anyhow. I’ll probably end up doing something about the description in the end too btw simply to tidy it up :slight_smile:

Yaaay I’m happy again now to make some nested rooms yipeee…

Yes, he’s afoot, isn’t he. :sunglasses:

(I may have been visiting Rock, Paper, Shotgun too much. The land where the puns roam freely, and a pun always is followed by a dozen more.)

I believe isCollectiveQuant is meant to separate input like >look at the pen from >look at the pens. In the first case the player probably wants to examine just one pen, and it’s appropriate to ask which one. In the second case the player wants to see them all, and it’s better to show the collective description.

For shoes, it’s not possible to know whether the player means one pair or all pairs in the absence of more specific details. So we override isCollectiveQuant to return true, and any time the parser would match a pair with vocabulary that also matches the group’s, the collective gets the first crack at handling the action (via isCollectiveAction).

The player can re-introduce ambiguity by adding specifics. If you set up your shoes like this:

+ sneakers: Shoes 'red sneakers' 'sneakers';
+ heels: Shoes 'red heels' 'heels';
+ flipflops: Shoes 'green flip/flops' 'flip flops';

Then >x green shoes will only match the flip flops, >x red shoes will want to disambiguate between the heels and the sneakers, and >x shoes will look at the pile.

You didn’t, before using isCollectiveAction, I’d simply used shoes as plural in the vocab words to disambiguate, which worked… Upto a point until whatever part of it that gave may have been interfering with the 2 functions, apart from that and few other bits I have in there our codes matched.

I’d have just copied my code in to show what I had but then I’d have had to have found it all, it’s not that I’m unorganised, I’m just pre organised for a later date :mrgreen: