aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2019-12-23 23:11:42 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2019-12-23 23:11:42 -0500
commita59b6c0cfdeb469cecb00648cf6b3c03627322b8 (patch)
treec8bed9dceb150d630ef3eddf2ede5d79e06f571e /examples
parent6c912dc1511c7eb17b2c2ff43c1023e8fb9aff78 (diff)
added vec.js
Diffstat (limited to 'examples')
-rw-r--r--examples/jarvis.js17
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);