Ensembles - ThePix/QuestJS GitHub Wiki

An ensemble is a collection of items that all exist in their own right, and can be handled as individual items, but when together it is more natural to refer to them by the whole. A good example of this would be a suit, which might be made up of trousers, jacket and waistcoat, each of which can be picked up, examined and put on in isolation to the others, but when they are together, it feels more natural to refer to them as a single item, the suit.

Here is an example of just such a suit.

createItem("suit_trousers", WEARABLE(2, ["lower"]), { 
  loc:"wardrobe",
  examine:"The trousers.",
  pronouns:PRONOUNS.plural
})

createItem("jacket", WEARABLE(3, ["upper"]), {
  loc:"wardrobe",
  examine:"The jacket", 
})

createItem("waistcoat", WEARABLE(2, ["upper", "lower"]), {
  loc:"wardrobe",
  examine:"The waistcoat",
})

createEnsemble("suit", [w.suit_trousers, w.jacket, w.waistcoat], {
  examine:"A complete suit.",
})

Note that the ensemble must be created after its components, using the createEnsemble function. It should be sent a name, an array of he components and a dictionary as usual when creating items. Note that you cannot use templates with an ensemble, though you can with the components.

Now when the user looks in her inventory, she will see suit if all three components are there, and the suit can be picked up and dropped as a single item. Note that in the side pane items are listed separately, and items must be put on individually (this may change in the future).

Ensembles are not implemented quite the same as a normal object, which means verbs and name modifiers do not work quite the same; you may discover other differences. They are orientated towards clothing, as that is the use-case I can think of, but can be modified as required.