Skip to content

New contributor Guide copy from

Mark Langsdorf edited this page Jun 30, 2021 · 1 revision

#Working with "copy-from" to overwrite an existing object# If you want to change the values of an existing monster or item in a mod, you can just create a copy of the item with the same id and new values. The CDDA loader will just overwrite the original values with the new ones. However, doing this can require a lot of work to just keep the modified version up to date and prevent the mod from breaking or causing undesired side effects if and when the original object gets changed.

This is where "copy-from" can come in handy. Aside from its use in defining similar objects, you can also use it to overwrite an existing object without having to redefine every property of it.

As an example, let's make pair of eclipse glasses as cheap as they probably would be.

  {
    "id": "eclipse_glasses",
    "copy-from": "eclipse_glasses",
    "type": "ARMOR",
    "name": { "str": "pair of eclipse glasses", "str_pl": "pairs of eclipse glasses" },
    "price": 100
  }

As shown in the example above, we are using "copy-from" on the very object id that we are overwriting.

Please note that we do define the "type" and "name" of the object, even though we don't necessarily make any changes to them. The game treats our object as a new item, regardless if or not we overwrite an existing one, so the mandatory properties have to be defined nonetheless.

We also defined a "price" of 100 (cents) turning the 25 $ glasses into a 1 $ product.

All the other properties, like "encumbrance", "material", "flags", "qualities" and protection or attack values, are getting copied from the base item.

You are not limited to items, the same will work on any object that supports the "copy-from" property, be it monsters, recipes, furniture or martial arts, to just name a few.

Mod loading order

Please keep in mind that your mod might not be the only one who modifies an existing object. If another mod uses "copy-from" to edit the same object as your use of "copy-from" but edits other properties than yours does, the two mods will not clash and work fine side by side.

If both mods edit the same property, the object will have the value of the last edit only. The mod load order will determine which edit is the last one.

Clone this wiki locally