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
29
30
31
32
33
34
|
'use strict'
const Operator = require('../operator')
function OperatorX (orca, x, y, passive) {
Operator.call(this, orca, x, y, 'x', true)
this.name = 'teleport'
this.info = 'Writes a distant operator with offset.'
this.ports.haste.x = { x: -2, y: 0 }
this.ports.haste.y = { x: -1, y: 0 }
this.ports.input.val = { x: 1, y: 0 }
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)
this.ports.output = { x: x, y: y, unlock: true }
}
this.run = function () {
if (!this.bang()) { return }
this.draw = false
const res = this.listen(this.ports.input.val)
this.output(`${res}`)
}
function clamp (v, min, max) { return v < min ? min : v > max ? max : v }
}
module.exports = OperatorX
|