Generally you would define every possible (clothing) item aviable in your story, which my $clothing structue was doing, and then use the keys of each of those defined items as needed.
So if you wanted to create different sets of clothing you could do somthing the following
<<set $clothingSets to {}>>
/* Add a 'two-piece' set. */
<<set $clothingSets["two-piece"] to ["t-shirt", "shorts", "shoes"] >>
/* Add a 'nice-dress' set. */
<<set $clothingSets["nice-dress"] to ["red-dress", "shoes"] >>
If you wanted to display a simple clothing sets list you could do something like
Clothes Sets: (simple)
<<nobr>>
<ul>
<<for _key range Object.keys($clothingSets)>>
\<li>_key : <<= $clothingSets[_key].join(", ")>></li>
<</for>>
</ul>
<</nobr>>
If you wanted that list to be a little more detailed you could do
Clothes Sets: (detailed)
<<nobr>>
<ul>
<<for _key range Object.keys($clothingSets)>>
\<li>_key : <<=
$clothingSets[_key]
.map(function (item) {
return State.variables.clothing[item].name;
})
.join(", ")>>
</li>
<</for>>
</ul>
<</nobr>>
...although you would ideally create your own custom functions to retrieve the Name of each of the relevant items from where those items are defined, and your own custom widgets/macros to display that information.
If you wanted to track what the player is currently wearing you could do something like.
/* Wear some clothes. */
<<set $wearing to {
top: "",
bottom: "",
feet: ""
}>>
<<set $wearing["top"] to "t-shirt" >>
<<set $wearing["bottom"] to "shorts" >>
If you wanted to list which items the player is currently wearing for could
You are currently wearing:
<<nobr>>
<ul>
<<for _slot range Object.keys($wearing)>>
\<li>_slot : <<if $wearing[_slot] is "">>Nothing<<else>><<= $clothing[$wearing[_slot]].name >><</if>></li>
<</for>>
</ul>
<</nobr>>
Note: If the definitions of your (clothing) items don't change during the life-cycle of a play-through then you may want to consider moving those definition from a story variable to the special setup object. Doing so reduces the amount of storage required by the History system (and related Save system), You could also do the same with the $clothingSets if there definitions also don't change once they have been initialised within StoryInit.
eg. Using setup instead of $clothing within your StoryInit.
/* Define all known clothing. */
<<set setup.clothing to {
"t-shirt": {
id: 3,
name: "T-shirt",
description: "blah blah blah",
covers: ["slot1"]
},
"shorts": {
id: 14,
name: "Tight Shorts",
description: "blah blah blah",
covers: ["slot2"]
},
"shoes": {
id: 18,
name: "Black shoes",
description: "blah blah blah",
covers: ["slot3"]
},
"red-dress": {
id: 26,
name: "Red Cocktail Dress",
description: "blah blah blah",
covers: ["slot1", "slot2"]
}
}>>
eg. Using setup instead of $clothing when displaying a detailed list of clothing sets.
Clothes Sets: (detailed using setup)
<<nobr>>
<ul>
<<for _key range Object.keys($clothingSets)>>
\<li>_key : <<=
$clothingSets[_key]
.map(function (item) {
return setup.clothing[item].name;
})
.join(", ")>>
</li>
<</for>>
</ul>
<</nobr>>