From 0cb377618e18baabb52b8e7bdef7a7dea15a3ec2 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 8 Dec 2019 09:28:50 -0600 Subject: [PATCH] add support for sequential compliments usage --- modules/default/compliments/compliments.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 59e11853..57675d19 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -36,9 +36,10 @@ Module.register("compliments", { morningStartTime: 3, morningEndTime: 12, afternoonStartTime: 12, - afternoonEndTime: 17 + afternoonEndTime: 17, + random: true }, - + lastIndexUsed:-1, // Set currentweather from module currentWeatherType: "", @@ -147,8 +148,20 @@ Module.register("compliments", { * return compliment string - A compliment. */ randomCompliment: function() { + // get the current time of day compliments list var compliments = this.complimentArray(); - var index = this.randomIndex(compliments); + variable for index to next message to display + let index=0 + // are we randomizing + if(this.config.random){ + // yes + index = this.randomIndex(compliments); + } + else{ + // no, sequetial + // if doing sequential, don't fall off the end + index = (this.lastIndexUsed >= (compliments.length-1))?0: ++this.lastIndexUsed + } return compliments[index]; },