diff options
author | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-26 17:38:30 -0500 |
---|---|---|
committer | Holden Rohrer <holden.rohrer@gmail.com> | 2019-12-27 14:57:57 -0500 |
commit | 22315bbaaa4d2a1642f6364c8666a2f8331d0ec3 (patch) | |
tree | 600adaea4639b29c835eaa711ef0b86d222083ef | |
parent | 0efff3e59c2c42308fc31bc0d79d01622c9833fd (diff) |
separated detectPrompt from tileHandler in jarvis
-rw-r--r-- | examples/jarvis.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/jarvis.js b/examples/jarvis.js index 167d0e3..f750903 100644 --- a/examples/jarvis.js +++ b/examples/jarvis.js @@ -32,15 +32,19 @@ function identity(send){ } var sender; + +function tileHandler(send, source, tiles){ + if (send == sender) return; + let locs = tilekeys(tiles); + detectPrompt(send, tiles, locs); +} + 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(search); var expire = {}; -function tileHandler(send, source, tiles){ - if (send == sender) return; //this may lead to issues later, but for now is used to count its own updates - let locs = tilekeys(tiles); - +function detectPrompt(send, tiles, locs){ // tries to detect the prompt ('jarvis') and calls respond if found. for (let i=0; i<locs.length; i++){ let loc = locs[i]; if (read.has(loc)){ |