aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/jarvis.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/examples/jarvis.js b/examples/jarvis.js
index 335b00e..49c425a 100644
--- a/examples/jarvis.js
+++ b/examples/jarvis.js
@@ -34,16 +34,24 @@ main.on('close', ()=>{
});
var sender; // Global variable that holds identity()'s `send` for tileHandler
+var initialized = false;
function identity(send){
sender = send;
console.log('identity activated');
+ if (! initialized){
+ initialized = true;
+ initOnce();
+ }
init();
main.on('tileUpdate', tileHandler);
}
function init(){
writes.enable();
+}
+
+function initOnce(){
notifRefresh();
}
@@ -65,13 +73,13 @@ notifsrc = '\
\n\
For a node.js YWOT api: \n\
& http://github.com/feynmansfedora/ywot-clean \n\
-& Try `jarvis` today. Uptime: UPTIME \n\
+& Try `j@rvis` today. Uptime: UPTIME \n\
'
var minsUp = 0;
var ctrl;
function notifRefresh(){
let newnotif = new Space();
- newnotif.loc = [-6, 20];
+ newnotif.loc = [-60, 20];
newnotif.adhoc(notifsrc.replace('UPTIME', Math.floor(minsUp/60) + 'h' + minsUp%60 + 'm'));
let diff = newnotif.copy();
if (typeof notif !== 'undefined') diff.comb(notif, comb.sub);
@@ -104,11 +112,11 @@ function protectArea(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.
+search.adhoc('j@rvis'); // 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 detectPrompt(send, tiles, locs){ // tries to detect the prompt ('jarvis') and calls respond if found.
+function detectPrompt(send, tiles, locs){ // tries to detect the prompt ('j@rvis') and calls respond if found.
for (let i=0; i<locs.length; i++){
let loc = locs[i];
if (read.has(loc)){