From c8a41857b503c96a5223e1f9b052cad4d9e65ffa Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Tue, 4 Feb 2020 17:54:59 -0500 Subject: [PATCH] Add weight attribute --- macrovision.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/macrovision.js b/macrovision.js index 5e174001..9b87c8e8 100644 --- a/macrovision.js +++ b/macrovision.js @@ -15,6 +15,9 @@ const unitChoices = { length: [ "meters", "kilometers" + ], + mass: [ + "kilograms" ] } const config = { @@ -173,6 +176,12 @@ function makeEntity() { power: 1, type: "length", base: math.unit(1, "meter") + }, + weight: { + name: "Weight", + power: 3, + type: "mass", + base: math.unit(80, "kg") } } } @@ -190,7 +199,7 @@ function makeEntity() { return math.multiply(Math.pow(this.parent.scale, this.attributes[key].power), this.attributes[key].base); }, set: function(value) { - const newScale = Math.pow(math.divide(value, this.attributes[key].base), this.attributes[key].power); + const newScale = Math.pow(math.divide(value, this.attributes[key].base), 1 / this.attributes[key].power); this.parent.scale = newScale; } }