Here is some sample code, where the problem occurs:
Before examining the bedside crate:
Instead say "A large wooden crate with a lid. [if open]Inside [is-are] [a list of things contained by the bedside crate].[otherwise]Resting on the lid [is-are] [a list of things on the crate lid].[end if]".
The problem is, if I put some dowels on the crate, it will say:
I know this is a beginners error, but I’m having a hard time understanding why this doesn’t work.
Please advise.
Plurality can’t predict that you are printing a list. It assigns singular or plural verbs to something that was just printed out, unless you specify which object you wan’t to determine plurality of (eg, [is-are of the noun]. There might be another extension that does what you want.
To elaborate a bit on Neil: Plurality doesn’t do any fancy analysis of your prose. It just looks at the last object you’ve printed (using a token like [the noun], for instance), and then it basis its prose on that. So if you have:
say "On [the noun] [is-are] [list of things enclosed by the noun]."
you will get “is” just in case the noun is singular. Of course, that is not what you want! Untested code, but I think something like this should work:
say "On the crate [if at least two things are on the crate]are[otherwise if at least one plural-named thing is on the crate]are[otherwise]is[end if] [list of things on the crate]."
You should have “are” if more than one thing is on the crate, or if the one thing is plural-named, and otherwise “is”. (Right? If I’m wrong, change the code accordingly.)
Thank you for the responses. That isn’t a very elegant solution, as this game is going to be pretty long and full of special descriptions.
Is there a way that I could do this with text substitution, where the list and the ‘is/are’ may be provided from somewhere else that constructs the prose? I would be grateful for a solution that can be easily applied to multiple descriptions with ease.
The other thing I could do is change the nouns to something like “a handful of dowels”, but that is more of a workaround and may not work in many cases.
Try “[is-are a list of things on the crate lid]”, as suggested in section 5.5 of the documentation. Note that there’s only one set of brackets.
Testing is a room. The bedside crate is a fixed in place closed container in testing.
The crate lid is part of the bedside crate. It is a supporter.
Before examining the bedside crate:
instead say "A large wooden crate with a lid. [if open]Inside [is-are a list of things contained by the bedside crate].[otherwise]Resting on the lid [is-are a list of things on the crate lid].[end if]".
Some wooden dowels are on the crate lid.
Thank you very much! I knew there would be some easier way to do this sort of thing, since I’m sure it comes up often enough. And I was about to start writing some complex text substitution function that took a list as a parameter somehow.