@frmds/transformers
v1.0.4
Published
Shared transformers for the Autodoc module of the Frontier Mods `.devtools`
Downloads
673
Readme
@frmds/transformers
transformers is the standard set of Autodoc transformers: the building blocks that compile a higher-level, composable, DRY mod source down into game-ready Cataclysm: Dark Days Ahead JSON.
These transformers are not run on their own. Autodoc loads and runs them while building a mod, and each one is independent, so you declare only the ones you want.
Install
bun add @frmds/transformersUsage
Declare the transformers under autodoc.transformers in your mod's frontier.json5. They run in declaration order:
autodoc: {
transformers: [
// every transformer this package ships
{ package: "@frmds/transformers", export: "ALL_TRANSFORMERS" },
// or a hand-picked subset, by export name
{ package: "@frmds/transformers", export: ["MATH_TRANSFORMER", "PRICE_TRANSFORMER"] },
],
}Without any transformers declared, none run. You must specify which transformers Autodoc should use for the mod.
Available transformers
Each transformer is independent and links to its own guide. Declare only the ones you want.
Author in any unit system and ship clean metric.
{ weight: "2 lbs" } // → { weight: "907 g 185 mg" }Describe an object's shape and get its volume and longest side.
// a shape's measurements become volume and longest_side
{ dimensions: { type: "cylinder", diameter: "2 in", length: "6 in" } }Derive an optic's field of view from a real aperture or distance.
{ field_of_view: { height: "1.8 m", distance: "100 m" } } // → 60Define a parameterized template once, then stamp it out by call.
// `pals/columns` turns a webbing column count into a real width
{ width: { fn: "pals/columns", args: [2] } }Share one parent definition across a family of objects.
// pull in chassis's properties, override what differs
{ id: "vest", type: "ITEM", inherit: "chassis" }ITEM_GROUP_VARIANTS_TRANSFORMER
Turn one spawn entry into a group per item variant.
// one group per variant, plus an `:any`
{ item: "vest", from: ["multicam", "black"] }Describe a pouch's design and get its computed pocket stats.
// a pouch design becomes encumbrance, ripoff, and moves
{ magazine_pouch: { type: "FLAP", capacity: 1 } }Compute values with full unit awareness.
// quantity-aware: 50 g, doubled, converted to kg
{ math: ["50 g", { op: "multiply", value: 2 }, { op: "convert", value: "kg" }] }
// → "0.1 kg"Apply structured edits to the object in place.
// append to an array without restating it
{ patch: [{ op: "append", key: "subtypes", value: "ARMOR" }] }Repeat an identical pocket by count.
// two identical pockets from one entry
{ pocket_type: "CONTAINER", multi: 2 }Rate an item by criteria and get a consistent barter price.
// rate by criteria, get a price off one shared curve
{ price_postapoc: { utility: "high", longevity: "high", scarcity: "high" } }
// → "51 USD"State a value once and point everything else at it.
// borrow stanag20's weight, so it tracks the source
{ weight: { ref: "stanag20", key: "weight" } }Expand a list of names into an item's full variant set.
// each name becomes a full variant
{ from: ["multicam", ["black", 2]] }