Browse Source

Allow attributes to have a default unit

This sets the unit that the attribute will be shown with. It
uses the same mechanism that's used to remember what units
you had selected.
master
Fen Dweller 4 years ago
parent
commit
a3722cc7a2
2 changed files with 15 additions and 4 deletions
  1. +7
    -0
      macrovision.js
  2. +8
    -4
      presets/characters.js

+ 7
- 0
macrovision.js View File

@@ -1581,9 +1581,16 @@ function makeEntity(info, views, sizes, forms = {}) {
} }


// to remember the units the user last picked // to remember the units the user last picked
// also handles default unit overrides


view.units = {}; view.units = {};


Object.entries(view.attributes).forEach(([key, val]) => {
if (val.defaultUnit !== undefined) {
view.units[key] = val.defaultUnit;
}
});

if ( if (
config.autoMass !== "off" && config.autoMass !== "off" &&
view.attributes.weight === undefined view.attributes.weight === undefined


+ 8
- 4
presets/characters.js View File

@@ -53,7 +53,8 @@ function makeCharacter(info, viewInfo, defaultSizes, forms) {
name: "Prey Capacity", name: "Prey Capacity",
power: 3, power: 3,
type: "volume", type: "volume",
base: value.preyCapacity
base: value.preyCapacity,
defaultUnit: "people"
} }
} }


@@ -56497,7 +56498,8 @@ characterMakers.push(() => makeCharacter(
name: "Shoe Size", name: "Shoe Size",
power: 1, power: 1,
type: "length", type: "length",
base: math.unit(14, "ShoeSizeMensUS")
base: math.unit(14, "ShoeSizeMensUS"),
defaultUnit: "ShoeSizeMensUS"
}, },
} }
}, },
@@ -56515,7 +56517,8 @@ characterMakers.push(() => makeCharacter(
name: "Shoe Size", name: "Shoe Size",
power: 1, power: 1,
type: "length", type: "length",
base: math.unit(14, "ShoeSizeMensUS")
base: math.unit(14, "ShoeSizeMensUS"),
defaultUnit: "ShoeSizeMensUS"
}, },
} }
}, },
@@ -56533,7 +56536,8 @@ characterMakers.push(() => makeCharacter(
name: "Shoe Size", name: "Shoe Size",
power: 1, power: 1,
type: "length", type: "length",
base: math.unit(14, "ShoeSizeMensUS")
base: math.unit(14, "ShoeSizeMensUS"),
defaultUnit: "ShoeSizeMensUS"
}, },
} }
}, },


Loading…
Cancel
Save