diff options
-rw-r--r-- | README (renamed from README.md) | 1 | ||||
-rw-r--r-- | examples/jarvis.js | 5 |
2 files changed, 4 insertions, 2 deletions
@@ -15,6 +15,7 @@ node examples/helloworld.js # To try out the hello world (read the code for more ## Quirks The server is a little bit weird sometimes. Most abstractions should work, but if you're trying to get into extending the code, be aware that: + - Each write only takes 200 characters - Each server command MUST be separated by about a second or you will be kicked (I recommend `tools/queue.js` for handling this) - On the backend, the server uses tiles to group data, but this has mostly been abstracted 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); } |