From a73606df8d833150a7771c919a9d15c3b2cee7b3 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Wed, 8 Jan 2020 18:06:31 -0500 Subject: added "call counter" to jarvis --- examples/jarvis.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/jarvis.js b/examples/jarvis.js index 065100d..6bf2286 100644 --- a/examples/jarvis.js +++ b/examples/jarvis.js @@ -84,14 +84,18 @@ var notifsrc = '\ \n\ For a node.js YWOT api: \n\ & http://github.com/feynmansfedora/ywot-clean \n\ -& Try `jarvis` today. Uptime: UPTIME \n\ +& Try `jarvis` today. Uptime: UPTIME. Called: JARVISx\n\ ' var minsUp = 0; +var callct = 0; var ctrl; function notifRefresh(){ let newnotif = new Space(); newnotif.loc = [-6, 20]; - newnotif.adhoc(notifsrc.replace('UPTIME', Math.floor(minsUp/60) + 'h' + minsUp%60 + 'm')); + text = notifsrc; + text = text.replace('UPTIME', Math.floor(minsUp/60) + 'h' + minsUp%60 + 'm'); + text = text.replace('JARVIS', callct); + newnotif.adhoc(text); let diff = newnotif.copy(); if (typeof notif !== 'undefined') diff.comb(notif, comb.sub); notif = newnotif; @@ -148,10 +152,10 @@ function detectPrompt(send, tiles, locs){ // tries to detect the prompt ('jarvis let response = new Space(); response.adhoc('yes, my liege'); -let writes = new Queue(1000, 200, (elems) => main.write(elems)); - function respond(coord){ console.log('called at', coord); + callct += 1; + notifRefresh(); response.loc = coord; writes.enqueue(...response.towrite()); read.update(response); -- cgit