Просмотр исходного кода

Add weight attribute

tags/v0.0.1
Fen Dweller 6 лет назад
Родитель
Сommit
c8a41857b5
1 измененных файлов: 10 добавлений и 1 удалений
  1. +10
    -1
      macrovision.js

+ 10
- 1
macrovision.js Просмотреть файл

@@ -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;
} }
} }


Загрузка…
Отмена
Сохранить