From a59b6c0cfdeb469cecb00648cf6b3c03627322b8 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Mon, 23 Dec 2019 23:11:42 -0500 Subject: added vec.js --- examples/jarvis.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/jarvis.js b/examples/jarvis.js index a94121c..9d4bb91 100644 --- a/examples/jarvis.js +++ b/examples/jarvis.js @@ -19,26 +19,29 @@ main.on('open', ()=>{ // Tries to identify itself with a cursor movement function detect(pos, send){ if (equals(pos[0],coords)){ main.off('cursor', detect); - this.emit('identity', send); + identity(send); } } }) -main.on('identity', (sender) => { // Does this need to be an event (or would a callback like identity(sender) work just as well?) +function identity(sender){ + console.log('identity activated'); var search = new Space(); search.adhoc('jarvis'); // The search space is the word jarvis, so whenever that's caught, a relevant function can be called. - var read = new Search(); + var read = new Search(search); var expire = {}; - main.on('tileUpdate', (send, source, tiles) => { + main.on('tileUpdate', (send, source, tiles) => { console.log(tiles); }); + /*main.on('tileUpdate', (send, source, tiles) => { + console.log('detected update', tiles); if (send == sender) return; let locs = tilekeys(tiles); for (let i=0; i { // Does this need to be an event (or would a c expire[loc] = setTimeout(()=>{read.del(loc)}, 30000); } - }); -}); + });*/ +} function respond(coord){ console.log('called at', coord); -- cgit