diff options
author | Devine Lu Linvega <[email protected]> | 2018-12-14 13:56:09 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-12-14 13:56:09 +1200 |
commit | 19c5f09d6c4479886e8324066108eae80a8a46b4 (patch) | |
tree | 9ea8e36f55c713e1d65afa081c26b1c441b9b2f2 | |
parent | e130e1ac9e64ef8c38585498b4e1556949fcaf48 (diff) | |
download | Orca-19c5f09d6c4479886e8324066108eae80a8a46b4.tar.gz Orca-19c5f09d6c4479886e8324066108eae80a8a46b4.zip |
Implemented input/output
-rw-r--r-- | desktop/core/library/_room.js | 11 | ||||
-rw-r--r-- | desktop/core/library/x.js | 4 | ||||
-rw-r--r-- | desktop/core/orca.js | 10 | ||||
-rw-r--r-- | desktop/sources/scripts/terminal.js | 2 |
4 files changed, 22 insertions, 5 deletions
diff --git a/desktop/core/library/_room.js b/desktop/core/library/_room.js index fdf8bc3..f0daf72 100644 --- a/desktop/core/library/_room.js +++ b/desktop/core/library/_room.js @@ -8,13 +8,20 @@ function OperatorRoom (orca, x, y, passive) { this.name = 'room' this.info = 'Hosts a nested Orca grid.' + this.ports.input.val = { x: 1, y: 0 } this.ports.haste.id = { x: -1, y: 0 } this.ports.output = { x: 0, y: 1 } this.run = function () { const id = this.listen(this.ports.haste.id) - if(!orca.terminal.rooms[id]){ return } - orca.terminal.rooms[id].run() + if (!orca.terminal.rooms[id]) { return } + + const val = this.listen(this.ports.input.val) + const room = orca.terminal.rooms[id] + room.input(val) + room.run() + const res = room.output() + this.output(`${res}`) } } diff --git a/desktop/core/library/x.js b/desktop/core/library/x.js index 9449461..85d0171 100644 --- a/desktop/core/library/x.js +++ b/desktop/core/library/x.js @@ -14,8 +14,8 @@ function OperatorX (orca, x, y, passive) { this.ports.output = { x: 0, y: 1, unlock: true } this.haste = function () { - const x = clamp(this.listen(this.ports.haste.x, true), 0, 24) - const y = clamp(this.listen(this.ports.haste.y, true), 1, 24) + const x = clamp(this.listen(this.ports.haste.x, true), 0, 32) + const y = clamp(this.listen(this.ports.haste.y, true), 1, 32) this.ports.output = { x: x, y: y, unlock: true } } diff --git a/desktop/core/orca.js b/desktop/core/orca.js index 3360436..6ed5143 100644 --- a/desktop/core/orca.js +++ b/desktop/core/orca.js @@ -105,6 +105,16 @@ function Orca (library = {}) { this.locks.push(`${x}:${y}`) } + // IO + + this.input = function (g) { + this.write(0, 0, g) + } + + this.output = function () { + return this.s.charAt(this.s.length - 1) + } + // Helpers this.inBounds = function (x, y) { diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index bac4510..7cd71d1 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -93,7 +93,7 @@ function Terminal (tile = { w: 20, h: 30 }) { } this.enter = function (id = 'hall') { - if (!this.rooms[id]) { this.rooms[id] = new Orca(library); this.rooms[id].reset(20, 13) } + if (!this.rooms[id]) { this.rooms[id] = new Orca(library); this.rooms[id].reset(33, 17) } console.log(`Enterting Room:${id}`) this.room = this.rooms[id] this.resize(false) |