diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/jarvis.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/examples/jarvis.js b/examples/jarvis.js index f31a9ea..ccf1f80 100644 --- a/examples/jarvis.js +++ b/examples/jarvis.js @@ -28,10 +28,16 @@ main.on('identity', (sender) => { console.log('identity activated'); main.on('tileUpdate', (send, source, tiles) => { if (send == sender) return; - let dim = tilekeys(tiles); - let data = new Space(); data.fromfetch(tiles, [dim[0][0],dim[0][1],dim[0][0],dim[0][1]],conform=false); - console.log(data.print()); - //let data = new Space(); data.fromfetch(tiles, dim); - //data.search - }) -}) + let locs = tilekeys(tiles); + for (let i=0; i<locs.length; i++){ + let loc = locs[i]; + if (read[loc]) clearTimeout(read[loc].timer); + read[loc] = ({ + "timer":setTimeout(()=>{delete read[dim]},30000), + "block":new Space(), + }); + read[loc].block.fromfetch(tiles, [loc[0][0], loc[0][1], loc[1][0], loc[1][1]], conform=false); + // TODO : if any pair or quadruplet of blocks are adjacent, SEARCH THEM! + } + }); +}); |