aboutsummaryrefslogtreecommitdiffhomepage
path: root/desktop/core/lib/x.js
blob: e248fb589d735adfc7248d634f4ef50d3d85bf11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict'

const FnBase = require('./_base')

function FnX (pico, x, y) {
  FnBase.call(this, pico, x, y)

  this.name = 'split'
  this.glyph = 'x'
  this.info = '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.operation = function () {
    if (this.west('0')) {
      this.fire(1, 0)
    }
    if (this.west('1')) {
      this.fire(0, 1)
    }
  }

  this.fire = function (x, y) {
    pico.add(this.x + x, this.y + y, 'b')
    pico.lock(this.x + x, this.y + y)
  }
}

module.exports = FnX