| @@ -15,6 +15,9 @@ const unitChoices = { | |||||
| length: [ | length: [ | ||||
| "meters", | "meters", | ||||
| "kilometers" | "kilometers" | ||||
| ], | |||||
| mass: [ | |||||
| "kilograms" | |||||
| ] | ] | ||||
| } | } | ||||
| const config = { | const config = { | ||||
| @@ -173,6 +176,12 @@ function makeEntity() { | |||||
| power: 1, | power: 1, | ||||
| type: "length", | type: "length", | ||||
| base: math.unit(1, "meter") | 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); | return math.multiply(Math.pow(this.parent.scale, this.attributes[key].power), this.attributes[key].base); | ||||
| }, | }, | ||||
| set: function(value) { | 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; | this.parent.scale = newScale; | ||||
| } | } | ||||
| } | } | ||||