Kaynağa Gözat

Add weight attribute

tags/v0.0.1
Fen Dweller 6 yıl önce
ebeveyn
işleme
c8a41857b5
1 değiştirilmiş dosya ile 10 ekleme ve 1 silme
  1. +10
    -1
      macrovision.js

+ 10
- 1
macrovision.js Dosyayı Görüntüle

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


Yükleniyor…
İptal
Kaydet