diff options
author | Devine Lu Linvega <[email protected]> | 2018-12-10 08:09:29 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-12-10 08:09:29 +1200 |
commit | 34ad407f4f1eae5b10ddde22a53301bafbc18551 (patch) | |
tree | 24fc66e2ec7519479186abae112c270aef9080c2 | |
parent | e570676e0da0871488be38eb81fdb386a5c12f89 (diff) | |
download | Orca-34ad407f4f1eae5b10ddde22a53301bafbc18551.tar.gz Orca-34ad407f4f1eae5b10ddde22a53301bafbc18551.zip |
Implemented new Q
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | desktop/core/library/q.js | 29 |
2 files changed, 23 insertions, 10 deletions
@@ -39,7 +39,7 @@ You can follow the [guide](GUIDE.md) to get started and play your first sounds. - `N` **north**: Moves Northward, or bangs. - `O` **offset**('x, 'y, val): Reads a distant operator with offset. - `P` **push**('len, 'key, val): Writes an eastward operator with offset. -- `Q` **query**('len): Counts the number of operators present eastwardly. +- `Q` **query**('x, 'y, 'len): Reads distant operators with offset. - `R` **random**(min, max): Outputs a random value. - `S` **south**: Moves southward, or bangs. - `T` **track**('len, 'key, val): Reads an eastward operator with offset. @@ -52,7 +52,7 @@ You can follow the [guide](GUIDE.md) to get started and play your first sounds. - `*` **bang**: Bangs neighboring operators. - `;` **udp**('len): Sends a string via UDP to localhost. - `:` **midi**('velocity, 'length, channel, octave, note): Sends Midi a midi note. -- `!` **keys**('key): Bangs on keyboard input. +- `!` **keys**(key): Bangs on keyboard input. - `#` **comment**: Comments a line, or characters until the next hash. ## Controls diff --git a/desktop/core/library/q.js b/desktop/core/library/q.js index a526342..f1d9ded 100644 --- a/desktop/core/library/q.js +++ b/desktop/core/library/q.js @@ -6,24 +6,37 @@ function OperatorQ (orca, x, y, passive) { Operator.call(this, orca, x, y, 'q', passive) this.name = 'query' - this.info = 'Counts the number of operators present eastwardly.' + this.info = 'Reads distant operators with offset.' + this.draw = false + this.ports.haste.x = { x: -3, y: 0 } + this.ports.haste.y = { x: -2, y: 0 } this.ports.haste.len = { x: -1, y: 0 } this.ports.output = { x: 0, y: 1 } this.haste = function () { - this.len = clamp(this.listen(this.ports.haste.len, true), 1, 24) - for (let x = 1; x <= this.len; x++) { - orca.lock(this.x + x, this.y) + this.ports.input = [] + this.len = clamp(this.listen(this.ports.haste.len, true), 1, 16) + const _x = this.listen(this.ports.haste.x, true) + const _y = this.listen(this.ports.haste.y, true) + for (let i = 1; i <= this.len; i++) { + this.ports.input.push({ x: i + _x, y: _y }) + orca.lock(this.x + this.ports.output.x + i - this.len, this.y + 1) } } this.run = function () { - let val = 0 - for (let x = 1; x <= this.len; x++) { - if (orca.glyphAt(this.x + x, this.y) !== '.') { val++ } + // Read + let str = '' + for (const id in this.ports.input) { + const port = this.ports.input[id] + const val = this.listen(port) + str += val + } + // Write + for (let i = 0; i < str.length; i++) { + orca.write(this.x + this.ports.output.x + i - str.length + 1, this.y + this.ports.output.y, str[i]) } - this.output(`${orca.keyOf(val)}`) } function clamp (v, min, max) { return v < min ? min : v > max ? max : v } |