diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/jarvis.js | 17 |
1 files changed, 10 insertions, 7 deletions
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<locs.length; i++){ let loc = locs[i]; - if read.has(loc) clearTimeout(expire[loc]); + if (read.has(loc)) clearTimeout(expire[loc]); let locspace = new Space(); locspace.fromfetch(tiles, [loc[0][0], loc[0][1], loc[1][0], loc[1][1]], conform=false); let results = read.add(locspace); @@ -46,8 +49,8 @@ main.on('identity', (sender) => { // 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); |