aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-05-31 11:40:17 +0900
committerDevine Lu Linvega <[email protected]>2019-05-31 11:40:17 +0900
commite0faf68ec5986b76c72bfaa386124622619a1a7d (patch)
treed3792cceb258bfcb218406c37b13dd007225e2ab
parent80faef4ed3e2e90e26d1cd647a5f3d0e71c63bfa (diff)
downloadOrca-e0faf68ec5986b76c72bfaa386124622619a1a7d.tar.gz
Orca-e0faf68ec5986b76c72bfaa386124622619a1a7d.zip
Cleaned up G
-rw-r--r--desktop/core/library/b.js2
-rw-r--r--desktop/core/library/c.js2
-rw-r--r--desktop/core/library/g.js17
-rw-r--r--desktop/core/operator.js11
4 files changed, 14 insertions, 18 deletions
diff --git a/desktop/core/library/b.js b/desktop/core/library/b.js
index 332e733..a3bf23a 100644
--- a/desktop/core/library/b.js
+++ b/desktop/core/library/b.js
@@ -15,7 +15,7 @@ export default function OperatorB (orca, x, y, passive) {
this.operation = function (force = false) {
const rate = this.listen(this.ports.rate, true)
const mod = this.listen(this.ports.mod, true) - 1
- const key = (Math.floor(orca.f / rate) % (mod * 2))
+ const key = Math.floor(orca.f / rate) % (mod * 2)
return orca.keyOf(key <= mod ? key : mod - (key - mod))
}
}
diff --git a/desktop/core/library/c.js b/desktop/core/library/c.js
index c038b98..38dc20e 100644
--- a/desktop/core/library/c.js
+++ b/desktop/core/library/c.js
@@ -15,7 +15,7 @@ export default function OperatorC (orca, x, y, passive) {
this.operation = function (force = false) {
const rate = this.listen(this.ports.rate, true)
const mod = this.listen(this.ports.mod, true)
- const val = (Math.floor(orca.f / rate) % mod)
+ const val = Math.floor(orca.f / rate) % mod
return orca.keyOf(val)
}
}
diff --git a/desktop/core/library/g.js b/desktop/core/library/g.js
index a001f3c..ba22d83 100644
--- a/desktop/core/library/g.js
+++ b/desktop/core/library/g.js
@@ -11,22 +11,19 @@ export default function OperatorG (orca, x, y, passive) {
this.ports.x = { x: -3, y: 0 }
this.ports.y = { x: -2, y: 0 }
this.ports.len = { x: -1, y: 0, clamp: { min: 1 } }
- this.ports.output = { x: 0, y: 1 }
this.operation = function (force = false) {
const len = this.listen(this.ports.len, true)
- for (let x = 1; x <= len; x++) {
- orca.lock(this.x + x, this.y)
- }
-
const x = this.listen(this.ports.x, true)
const y = this.listen(this.ports.y, true) + 1
- this.ports.output = { x: x, y: y }
- // Read
- for (let i = 0; i < len; i++) {
- const port = { x: i + 1, y: 0 }
+ for (let offset = 0; offset <= len; offset++) {
+ if (offset > 0) {
+ orca.lock(this.x + offset, this.y)
+ }
+ const port = { x: offset + 1, y: 0 }
const value = this.listen(port)
- orca.write(this.x + x + i, this.y + y, value)
+ orca.write(this.x + x + offset, this.y + y, value)
}
+ this.ports.output = { x: x, y: y }
}
}
diff --git a/desktop/core/operator.js b/desktop/core/operator.js
index be02e3f..c0d9397 100644
--- a/desktop/core/operator.js
+++ b/desktop/core/operator.js
@@ -41,15 +41,10 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) {
this.permissions = function () {
for (const id in this.ports) {
- const port = this.ports[id]
- orca.lock(this.x + port.x, this.y + port.y)
+ orca.lock(this.x + this.ports[id].x, this.y + this.ports[id].y)
}
}
- this.operation = function () {
-
- }
-
this.run = function (force = false) {
this.draw = true
const payload = this.operation(force)
@@ -62,6 +57,10 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) {
}
}
+ this.operation = function () {
+
+ }
+
// Helpers
this.lock = function () {