aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/jarvis.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/jarvis.js b/examples/jarvis.js
index 14bbaf7..0f0e1f1 100644
--- a/examples/jarvis.js
+++ b/examples/jarvis.js
@@ -42,12 +42,13 @@ function open(){
console.log('socket opened');
let coords = [Math.floor(Math.random()*100000+16),Math.floor(Math.random()*100000+16)];
main.cursor(coords);
- main.once('cursor', detect);
+ main.on('cursor', detect);
function detect(pos, send){
if (vec.equals(pos[0],coords)){
main.off('cursor', detect);
identity(send);
}
+ main.off('cursor', detect);
}
}
@@ -151,7 +152,6 @@ function detectPrompt(send, tiles, locs){ // tries to detect the prompt ('jarvis
if (results.length > 0) respond(results, send);
expire[loc] = setTimeout(() => {read.del(loc); delete expire[loc];}, 30000);
}
- limits.push(send);
}
let response = new Space();
@@ -166,4 +166,5 @@ function respond(coord, send){
writes.enqueue(response.towrite().concat(notifRefresh()));
read.update(response);
setTimeout(() => {limits.splice(limits.indexOf(send))}, 5*1000);
+ limits.push(send);
}