diff options
author | Devine Lu Linvega <[email protected]> | 2018-10-19 10:46:15 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-10-19 10:46:15 +1200 |
commit | add55227a3bbd11d8850c05541cd04da5ab36641 (patch) | |
tree | 9229cf3d4a54855411db1857342974cc519a79ea | |
parent | 49c5e2e52aaec8a81ab17a7faff103ee4ed68181 (diff) | |
download | Orca-add55227a3bbd11d8850c05541cd04da5ab36641.tar.gz Orca-add55227a3bbd11d8850c05541cd04da5ab36641.zip |
Improved Base class
33 files changed, 78 insertions, 98 deletions
@@ -10,7 +10,7 @@ - `A`, **add**(math): Creates the result of the addition of east and west fns, southward. - `B`, **<missing name>**: Missing docs. -- `C`, **<missing name>**: Missing docs. +- `C`, **count**(list): Count the number of fns present eastwardly. - `D`, **<missing name>**: Missing docs. - `E`, **east**(direction): Moves eastward, or bangs. - `F`, **if**(math): Bangs if east and west fns are equal, southward. @@ -23,15 +23,15 @@ - `M`, **modulo**(math): Creates the result of the modulo operation of east and west fns, southward. - `N`, **north**(direction): Moves Northward, or bangs. - `O`, **<missing name>**: Missing docs. -- `P`, **push**(direction): Moves away, on bang. +- `P`, **<missing name>**: Missing docs. - `Q`, **query**: Call a function by name, freezes 3 characters eastward. - `R`, **raycast**(transport): Sends a bang to the nearest fn following the direction of the bang. - `S`, **south**(direction): Moves southward, or bangs. - `T`, **trigger**: Bangs southward in the presence of `1`, `N`, `S`, `W`, `E` or `Z` northward. - `U`, **<missing name>**: Missing docs. -- `V`, **value**: Creates a numerical value between 0 and 5 based on the number of present _fns_ westward. +- `V`, **<missing name>**: Missing docs. - `W`, **west**(direction): Moves westward, or bangs. -- `X`, **split**: [FIX]Bangs eastward when westward fn is 0, and southward when fn is 1. +- `X`, **split**: Bangs eastward when westward fn is 0, and southward when fn is 1. - `Y`, **type**(math): Compares the type(num/alpha/special) of westward and eastward fns, and return 1 or 0 southward. - `Z`, **creep**: Moves to a the next available location in a cycle of E, S, W, N based on the runtime frame. @@ -49,12 +49,13 @@ ### Functions(By Type) - **maths**: `a` `f` `m` `y`. -- **miscs**: `.` `.` `.` `j` `.` `:` `t` `.` `v` `x` `z` `.` `*`. -- **directions**: `e` `n` `p` `s` `w`. +- **miscs**: `.` `.` `j` `.` `.` `q` `t` `.` `v` `x` `z` `.` `*`. +- **lists**: `c` `l`. +- **directions**: `e` `n` `s` `w`. - **transports**: `g` `r`. - **stoppers**: `h`. - **triggers**: `i` `k`. -- **lists**: `l`. + ## CLI diff --git a/desktop/core/lib/__bpm.js b/desktop/core/lib/__bpm.js index 9662882..6877866 100644 --- a/desktop/core/lib/__bpm.js +++ b/desktop/core/lib/__bpm.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnBpm (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, '?', passive) this.type = 'midi' this.name = 'bpm' - this.glyph = '?' this.info = 'Sets the speed for the Pico terminal.' this.ports = [{ x: 1, y: 0, output: true }, { x: 2, y: 0, output: true }, { x: 3, y: 0, output: true }] diff --git a/desktop/core/lib/__qqq.js b/desktop/core/lib/__qqq.js index e88f5bd..2e2c75c 100644 --- a/desktop/core/lib/__qqq.js +++ b/desktop/core/lib/__qqq.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnQqq (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, '?', passive) this.type = 'midi' this.name = 'qqq' - this.glyph = '?' this.info = 'Plays note, on channel, with octave.' this.ports = [{ x: 0, y: -1, output: true }, { x: 1, y: 0, output: true }, { x: 2, y: 0, output: true }] diff --git a/desktop/core/lib/__vol.js b/desktop/core/lib/__vol.js index 51c6273..080a07f 100644 --- a/desktop/core/lib/__vol.js +++ b/desktop/core/lib/__vol.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnVol (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, '?', passive) this.type = 'midi' this.name = 'volume' - this.glyph = '?' this.info = 'Sets the volume for the Pico terminal.' this.ports = [{ x: 1, y: 0, output: true }, { x: 2, y: 0, output: true }, { x: 3, y: 0, output: true }] diff --git a/desktop/core/lib/_bang.js b/desktop/core/lib/_bang.js index ecbde8e..db6e148 100644 --- a/desktop/core/lib/_bang.js +++ b/desktop/core/lib/_bang.js @@ -3,10 +3,9 @@ const FnBase = require('./_base') function FnBang (pico, x, y, passive) { - FnBase.call(this, pico, x, y, true) + FnBase.call(this, pico, x, y, '*', true) this.name = 'bang' - this.glyph = '*' this.info = 'Bangs!' this.haste = function () { diff --git a/desktop/core/lib/_base.js b/desktop/core/lib/_base.js index 5b537c6..338769a 100644 --- a/desktop/core/lib/_base.js +++ b/desktop/core/lib/_base.js @@ -1,11 +1,11 @@ 'use strict' -function FnBase (pico, x, y, passive = false) { +function FnBase (pico, x, y, glyph = '.', passive = false) { this.x = x this.y = y this.passive = passive this.name = '<missing name>' - this.glyph = '.' + this.glyph = passive ? glyph.toUpperCase() : glyph this.type = 'misc' this.info = 'Missing docs.' this.ports = [] diff --git a/desktop/core/lib/_null.js b/desktop/core/lib/_null.js index 1474be7..c682f34 100644 --- a/desktop/core/lib/_null.js +++ b/desktop/core/lib/_null.js @@ -3,10 +3,9 @@ const FnBase = require('./_base') function FnNull (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, '.', passive) this.name = 'null' - this.glyph = '.' this.info = 'void' } diff --git a/desktop/core/lib/a.js b/desktop/core/lib/a.js index 22f1616..c6b625b 100644 --- a/desktop/core/lib/a.js +++ b/desktop/core/lib/a.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnA (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'a', passive) this.type = 'math' this.name = 'add' - this.glyph = 'a' this.info = 'Creates the result of the addition of east and west fns, southward.' this.ports.push({ x: -1, y: 0 }) diff --git a/desktop/core/lib/b.js b/desktop/core/lib/b.js index 6812712..5e91fe3 100644 --- a/desktop/core/lib/b.js +++ b/desktop/core/lib/b.js @@ -3,7 +3,7 @@ const FnBase = require('./_base') function FnB (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'b', passive) } module.exports = FnB diff --git a/desktop/core/lib/c.js b/desktop/core/lib/c.js index d93fb3b..4711be5 100644 --- a/desktop/core/lib/c.js +++ b/desktop/core/lib/c.js @@ -3,7 +3,40 @@ const FnBase = require('./_base') function FnC (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'c', passive) + + this.type = 'list' + this.name = 'count' + this.info = 'Count the number of fns present eastwardly.' + + this.ports.push({ x: 0, y: 1, output: true }) + this.ports.push({ x: -1, y: 0, input: true }) + + if (pico) { + this.w = this.west() + this.len = this.w ? pico.allowed.indexOf(this.w.glyph) : 0 + for (let x = 1; x <= this.len; x++) { + this.ports.push({ x: x, y: 0, input: true }) + } + } + + this.haste = function () { + for (let x = 1; x <= this.len; x++) { + pico.lock(this.x + x, this.y) + } + pico.lock(this.x, this.y + 1) + } + + this.operation = function () { + if (!this.len || this.len < 1) { return } + let count = 0 + for (let x = 1; x <= this.len; x++) { + const g = pico.glyphAt(this.x + x, this.y) + if (g !== '.') { count++ } + } + const ch = pico.allowed.indexOf(`${count}`) + pico.add(this.x, this.y + 1, `${pico.allowed[ch]}`) + } } module.exports = FnC diff --git a/desktop/core/lib/d.js b/desktop/core/lib/d.js index 6e175dd..39594a5 100644 --- a/desktop/core/lib/d.js +++ b/desktop/core/lib/d.js @@ -3,7 +3,7 @@ const FnBase = require('./_base') function FnD (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'd', passive) } module.exports = FnD diff --git a/desktop/core/lib/e.js b/desktop/core/lib/e.js index ca6d608..7d6475e 100644 --- a/desktop/core/lib/e.js +++ b/desktop/core/lib/e.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnE (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'e', passive) this.type = 'direction' this.name = 'east' - this.glyph = passive ? 'E' : 'e' this.info = 'Moves eastward, or bangs.' this.haste = function () { diff --git a/desktop/core/lib/f.js b/desktop/core/lib/f.js index 70b079f..1095282 100644 --- a/desktop/core/lib/f.js +++ b/desktop/core/lib/f.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnF (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'f', passive) this.type = 'math' this.name = 'if' - this.glyph = 'f' this.info = 'Bangs if east and west fns are equal, southward.' this.ports.push({ x: -1, y: 0 }) this.ports.push({ x: 1, y: 0 }) diff --git a/desktop/core/lib/g.js b/desktop/core/lib/g.js index 3d75670..5db9db1 100644 --- a/desktop/core/lib/g.js +++ b/desktop/core/lib/g.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnG (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'g', passive) this.type = 'transport' this.name = 'generator' - this.glyph = 'g' this.info = 'Generates a direction fn from bang.' this.operation = function () { diff --git a/desktop/core/lib/h.js b/desktop/core/lib/h.js index 000483d..8027da1 100644 --- a/desktop/core/lib/h.js +++ b/desktop/core/lib/h.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnH (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'h', passive) this.type = 'stopper' this.name = 'halt' - this.glyph = 'h' this.info = 'Stops southward fn from operating.' this.ports.push({ x: 0, y: 1, output: true }) diff --git a/desktop/core/lib/i.js b/desktop/core/lib/i.js index 63496ce..0614008 100644 --- a/desktop/core/lib/i.js +++ b/desktop/core/lib/i.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnI (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'i', passive) this.type = 'trigger' this.name = 'increment' - this.glyph = 'i' this.info = 'Increments southward numeric fn on bang.' this.ports.push({ x: 0, y: 1, output: true }) this.ports.push({ x: 1, y: 0, input: true }) diff --git a/desktop/core/lib/j.js b/desktop/core/lib/j.js index f94dc5c..d42f8da 100644 --- a/desktop/core/lib/j.js +++ b/desktop/core/lib/j.js @@ -3,10 +3,9 @@ const FnBase = require('./_base') function FnJ (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'j', passive) this.name = 'jump' - this.glyph = 'j' this.info = 'Copies the northward fn, southwardly.' this.ports.push({ x: 0, y: -1, input: true }) this.ports.push({ x: 0, y: 1, output: true }) diff --git a/desktop/core/lib/k.js b/desktop/core/lib/k.js index a8c0cd2..83be05a 100644 --- a/desktop/core/lib/k.js +++ b/desktop/core/lib/k.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnK (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'k', passive) this.type = 'trigger' this.name = 'kill' - this.glyph = 'k' this.info = 'Kills southward fns, on bang.' this.ports.push({ x: 0, y: 1, output: true }) diff --git a/desktop/core/lib/l.js b/desktop/core/lib/l.js index df67b74..4f0b1e0 100644 --- a/desktop/core/lib/l.js +++ b/desktop/core/lib/l.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnL (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'l', passive) this.type = 'list' this.name = 'loop' - this.glyph = 'l' this.info = 'Loop a number of characters ahead.' this.ports.push({ x: -1, y: 0, input: true }) diff --git a/desktop/core/lib/m.js b/desktop/core/lib/m.js index 9d3cf9f..d44023c 100644 --- a/desktop/core/lib/m.js +++ b/desktop/core/lib/m.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnM (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'm', passive) this.type = 'math' this.name = 'modulo' - this.glyph = 'm' this.info = 'Creates the result of the modulo operation of east and west fns, southward.' this.ports.push({ x: -1, y: 0 }) this.ports.push({ x: 1, y: 0 }) diff --git a/desktop/core/lib/n.js b/desktop/core/lib/n.js index 77417f4..05fbe90 100644 --- a/desktop/core/lib/n.js +++ b/desktop/core/lib/n.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnN (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'n', passive) this.type = 'direction' this.name = 'north' - this.glyph = passive ? 'N' : 'n' this.info = 'Moves Northward, or bangs.' this.haste = function () { diff --git a/desktop/core/lib/o.js b/desktop/core/lib/o.js index b484649..8942cfc 100644 --- a/desktop/core/lib/o.js +++ b/desktop/core/lib/o.js @@ -3,7 +3,7 @@ const FnBase = require('./_base') function FnO (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'o', passive) } module.exports = FnO diff --git a/desktop/core/lib/p.js b/desktop/core/lib/p.js index 0a5e66f..b9f5de8 100644 --- a/desktop/core/lib/p.js +++ b/desktop/core/lib/p.js @@ -3,27 +3,7 @@ const FnBase = require('./_base') function FnP (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) - - this.type = 'direction' - this.name = 'push' - this.glyph = 'p' - this.info = 'Moves away, on bang.' - - this.operation = function () { - const origin = this.bang() - - if (!origin) { return } - - const direction = { x: this.x - origin.x, y: this.y - origin.y } - const pushed = this.neighbor_by(direction.x, direction.y) - - this.move(direction.x, direction.y) - - if (pushed) { - pico.add(this.x + (direction.x * 2), this.y + (direction.y * 2), pushed.glyph) - } - } + FnBase.call(this, pico, x, y, 'p', passive) } module.exports = FnP diff --git a/desktop/core/lib/q.js b/desktop/core/lib/q.js index 8c2f521..29dc0c0 100644 --- a/desktop/core/lib/q.js +++ b/desktop/core/lib/q.js @@ -3,10 +3,9 @@ const FnBase = require('./_base') function FnQ (pico, x, y, passive) { - FnBase.call(this, pico, x, y, true) + FnBase.call(this, pico, x, y, 'q', true) this.name = 'query' - this.glyph = ':' this.info = 'Call a function by name, freezes 3 characters eastward.' if (pico) { diff --git a/desktop/core/lib/r.js b/desktop/core/lib/r.js index 8284c73..f5d32a5 100644 --- a/desktop/core/lib/r.js +++ b/desktop/core/lib/r.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnR (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'r', passive) this.type = 'transport' this.name = 'raycast' - this.glyph = 'r' this.info = 'Sends a bang to the nearest fn following the direction of the bang.' this.operation = function () { diff --git a/desktop/core/lib/s.js b/desktop/core/lib/s.js index 9a4c25d..6828dc3 100644 --- a/desktop/core/lib/s.js +++ b/desktop/core/lib/s.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnS (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 's', passive) this.type = 'direction' this.name = 'south' - this.glyph = passive ? 'S' : 's' this.info = 'Moves southward, or bangs.' this.haste = function () { diff --git a/desktop/core/lib/t.js b/desktop/core/lib/t.js index b5276ae..e6b479a 100644 --- a/desktop/core/lib/t.js +++ b/desktop/core/lib/t.js @@ -3,10 +3,9 @@ const FnBase = require('./_base') function FnT (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 't', passive) this.name = 'trigger' - this.glyph = 't' this.info = 'Bangs southward in the presence of `1`, `N`, `S`, `W`, `E` or `Z` northward.' this.ports = [{ x: -1, y: 0, bang: true }, { x: 0, y: 1, output: true }] diff --git a/desktop/core/lib/u.js b/desktop/core/lib/u.js index 161ed2d..c6e3d91 100644 --- a/desktop/core/lib/u.js +++ b/desktop/core/lib/u.js @@ -3,7 +3,7 @@ const FnBase = require('./_base') function FnU (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'u', passive) } module.exports = FnU diff --git a/desktop/core/lib/v.js b/desktop/core/lib/v.js index 0c6ee91..842b483 100644 --- a/desktop/core/lib/v.js +++ b/desktop/core/lib/v.js @@ -3,19 +3,7 @@ const FnBase = require('./_base') function FnV (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) - - this.name = 'value' - this.glyph = 'v' - this.info = 'Creates a numerical value between 0 and 5 based on the number of present _fns_ westward.' - this.ports = [{ x: -1, y: 0 }, { x: -2, y: 0 }, { x: -3, y: 0 }, { x: -4, y: 0 }, { x: -5, y: 0 }] - - this.operation = function () { - const val = (pico.glyphAt(this.x - 1, this.y) !== '.' ? 1 : 0) + (pico.glyphAt(this.x - 2, this.y) !== '.' ? 1 : 0) + (pico.glyphAt(this.x - 3, this.y) !== '.' ? 1 : 0) + (pico.glyphAt(this.x - 4, this.y) !== '.' ? 1 : 0) + (pico.glyphAt(this.x - 5, this.y) !== '.' ? 1 : 0) - - pico.add(this.x + 1, this.y, val + '') - pico.lock(this.x + 1, this.y) - } + FnBase.call(this, pico, x, y, 'v', passive) } module.exports = FnV diff --git a/desktop/core/lib/w.js b/desktop/core/lib/w.js index 1ea6e95..0ee27a2 100644 --- a/desktop/core/lib/w.js +++ b/desktop/core/lib/w.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnW (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'w', passive) this.type = 'direction' this.name = 'west' - this.glyph = passive ? 'W' : 'w' this.info = 'Moves westward, or bangs.' this.haste = function () { diff --git a/desktop/core/lib/x.js b/desktop/core/lib/x.js index 9b321c9..a7ef9d0 100644 --- a/desktop/core/lib/x.js +++ b/desktop/core/lib/x.js @@ -3,12 +3,13 @@ const FnBase = require('./_base') function FnX (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'x', passive) this.name = 'split' - this.glyph = 'x' - this.info = '[FIX]Bangs eastward when westward fn is 0, and southward when fn is 1.' - this.ports = [{ x: -1, y: 0 }, { x: 0, y: 1, output: true }, { x: 1, y: 0, output: true }] + this.info = 'Bangs eastward when westward fn is 0, and southward when fn is 1.' + this.ports.push({ x: -1, y: 0 }) + this.ports.push({ x: 0, y: 1, output: true }) + this.ports.push({ x: 1, y: 0, output: true }) this.operation = function () { if (this.west('0')) { diff --git a/desktop/core/lib/y.js b/desktop/core/lib/y.js index 31c768c..fce8f3e 100644 --- a/desktop/core/lib/y.js +++ b/desktop/core/lib/y.js @@ -3,11 +3,10 @@ const FnBase = require('./_base') function FnY (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'y', passive) this.type = 'math' this.name = 'type' - this.glyph = 'y' this.info = 'Compares the type(num/alpha/special) of westward and eastward fns, and return 1 or 0 southward.' this.ports.push({ x: -1, y: 0, input: true }) this.ports.push({ x: 1, y: 0, input: true }) diff --git a/desktop/core/lib/z.js b/desktop/core/lib/z.js index af8458e..eff7c1c 100644 --- a/desktop/core/lib/z.js +++ b/desktop/core/lib/z.js @@ -3,10 +3,9 @@ const FnBase = require('./_base') function FnZ (pico, x, y, passive) { - FnBase.call(this, pico, x, y, passive) + FnBase.call(this, pico, x, y, 'z', passive) this.name = 'creep' - this.glyph = 'z' this.info = 'Moves to a the next available location in a cycle of E, S, W, N based on the runtime frame.' this.haste = function () { |