aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--desktop/core/library/_midi.js2
-rw-r--r--desktop/core/library/v.js40
-rw-r--r--examples/variables.orca13
3 files changed, 44 insertions, 11 deletions
diff --git a/desktop/core/library/_midi.js b/desktop/core/library/_midi.js
index 4125ca1..1aa09d4 100644
--- a/desktop/core/library/_midi.js
+++ b/desktop/core/library/_midi.js
@@ -24,7 +24,7 @@ function OperatorMidi (orca, x, y, passive) {
if (rawOctave === 0 || rawNote === 0) { return }
this.draw = false
-
+
const notes = ['C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'B']
// 0 - 16
const channel = clamp(rawChannel, 0, 15)
diff --git a/desktop/core/library/v.js b/desktop/core/library/v.js
index d0a0ba0..21225ee 100644
--- a/desktop/core/library/v.js
+++ b/desktop/core/library/v.js
@@ -5,25 +5,45 @@ const Operator = require('../operator')
function OperatorV (orca, x, y, passive) {
Operator.call(this, orca, x, y, 'v', passive)
- this.name = 'beam'
- this.info = 'Bangs the nearest southward operator on bang.'
+ this.name = 'variable'
+ this.info = 'Reads and write globally available variables.'
- this.ports.output = { x: 0, y: 1, unlock: true }
+ this.ports.haste.write = { x: -1, y: 0 }
+ this.ports.input.value = { x: 1, y: 0 }
+ this.ports.output = { x: 0, y: 1 }
this.haste = function () {
- while (orca.inBounds(this.x + this.ports.output.x, this.y + this.ports.output.y)) {
- this.ports.output.y += 1
- if (this.listen(this.ports.output) !== '.' && this.listen(this.ports.output) !== '*') { break }
+ const key = this.listen(this.ports.haste.write, true)
+
+ if (key > 9) {
+ this.ports.output = null
}
- this.ports.output.y -= 1
}
this.run = function () {
- if (!this.bang()) { return }
+ if (this.listen(this.ports.haste.write, true) > 9) { return }
+
+ const key = this.listen(this.ports.input.value)
+ const res = this.read(key)
+
+ if (res !== '.') {
+ this.output(`${res}`)
+ }
+ }
- this.draw = false
+ this.read = function (key) {
+ for (const id in orca.runtime) {
+ const operator = orca.runtime[id]
+ if (orca.lockAt(operator.x, operator.y)) { continue }
+ const glyph = operator.glyph.toLowerCase()
+ if (glyph !== 'v') { continue }
+ const write = operator.listen(operator.ports.haste.write)
+ if (write !== key) { continue }
+ const value = operator.listen(operator.ports.input.value)
+ return value
+ }
- this.output(`*`)
+ return null
}
}
diff --git a/examples/variables.orca b/examples/variables.orca
new file mode 100644
index 0000000..1a228a5
--- /dev/null
+++ b/examples/variables.orca
@@ -0,0 +1,13 @@
+.........................................
+.#.VARIABLES.#....R.3.R.3.R.3............
+................aV1.bV2.cV2..............
+...Va.Vb.Vc..............................
+...1..2..2...............................
+...J..J..J.......#.READ.#................
+...1Y12Y22...............................
+.....JJ.JJ...............................
+....A12A22.......Va..Vb..Vc..............
+....3Y34.........1...2...2...............
+......JJ.................................
+......34.................................
+......................................... \ No newline at end of file