Add a customizable weight formatter function
This commit is contained in:
parent
6e2dfa1cf1
commit
44372d0a17
3 changed files with 23 additions and 7 deletions
12
module/utils/formatWeight.mjs
Normal file
12
module/utils/formatWeight.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
import { toPrecision } from "./roundToPrecision.mjs";
|
||||
|
||||
/**
|
||||
* Formats a numerical value as a weight.
|
||||
*
|
||||
* @param {number} weight The numerical weight to format
|
||||
*/
|
||||
export function formatWeight(weight) {
|
||||
const unit = game.settings.get(__ID__, `weightUnit`);
|
||||
return toPrecision(weight, 2) + unit;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue