diff --git a/hugvey/story.py b/hugvey/story.py index 766319b..d90eaa5 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -143,7 +143,7 @@ class Message(object): # self.logger.debug(f"Getting text for {self.id}") for var in self.variables: self.logger.debug(f"try replacing ${var} with {self.variableValues[var]} in {text}") - replacement = self.variableValues[var] if (self.variableValues[var] is not None) else "nothing" #TODO: translate nothing to each language + replacement = self.variableValues[var] if (self.variableValues[var] is not None) else self.story.configuration.nothing_text #TODO: translate nothing to each language text = text.replace('$'+var, replacement) return text @@ -942,7 +942,8 @@ class Diversion(object): class Configuration(object): id = 'configuration' - volume = 1 + volume = 1 # Volume multiplier for 'play' command + nothing_text = "nothing" # When variable is not set, but used in sentence, replace it with this word. @classmethod def initFromJson(configClass, data, story): diff --git a/www/js/hugvey_console.js b/www/js/hugvey_console.js index 0b4614d..cbc888a 100644 --- a/www/js/hugvey_console.js +++ b/www/js/hugvey_console.js @@ -889,6 +889,19 @@ class Graph { }, 'value': this.configuration.hasOwnProperty('volume') ? this.configuration.volume : 1 }) + ), + crel( + 'label', + "Text replacement when no variable is set: ", + crel('input', { + 'type': 'text', + 'on': { + 'change': function(e){ + panopticon.graph.configuration['nothing_text'] = parseFloat(e.target.value) + } + }, + 'value': this.configuration.hasOwnProperty('nothing_text') ? this.configuration.nothing_text : "nothing" + }) ) );