diff --git a/lights.js b/lights.js index f81f4d4..01808ff 100644 --- a/lights.js +++ b/lights.js @@ -42,9 +42,13 @@ let functions = { constant: (index, args, prev) => { return args; }, modulo: (index, args, prev) => { return prev % args; }, move: (index, args, prev) => { targets[args] = prev; return prev; }, - swap: (index, args, prev) => { let temp = targets[args]; targets[args] = prev; return temp; } + swap: (index, args, prev) => { let temp = targets[args]; targets[args] = prev; return temp; }, + add: (index, args, prev) => { return prev + args; }, + subtract: (index, args, prev) => { return prev - args; } } +export functions; + function tick_pattern() { // do the parsing stuff here log.debug("TICKING PATTERN") diff --git a/server.js b/server.js index 6ff566b..80b23e9 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,5 @@ import * as net from 'net'; +import { functions } from './lights.js' const hostname = '0.0.0.0'; const port = 29999; @@ -9,6 +10,7 @@ export function recv(callback, errorCallback) { server.on('connection', (con) => { console.log('connection recieved: ' + con.remoteAddress + ":" + con.remotePort); + con.write(JSON.stringify(Object.keys(functions))); con.on('data', (data) => { callback(data); });