Template: COMPONENT - ThePix/QuestJS GitHub Wiki

A component is a part of another item; it is assumed the component cannot be removed. In the tutorial, the battery compartment for the charger was set up as a component.

The COMPONENT template needs the name of the object that it is part of. That is all there is to it!

You do need to create the item it is a part of before hand. Any component will have component set to true, whilst the whole item will have componentHolder set to true.

You cannot add components to a container or surface.

If your component's description depends on the state of the the main object, you can set its examine attribute to use a text processor directive like this:

createItem("protrusion", COMPONENT("machine"), {
  examine:"The protrusion is about two inches long{select:machine:protrusionDescriptions:state}.",
})

As the description is based on the state of the containing object, the text directive will expect the descriptions to be there. Perhaps like this:

createItem("machine", {
  loc:'lab',
  state:0,
  protrusionDescriptions:[
    ', and made of a dull metal',
    ', and made of a dull metal. It feels warm',
    '; the metal is glowing red',
  ],
})