Nothing text ##54

This commit is contained in:
Ruben van de Ven 2019-05-13 14:45:52 +02:00
parent fefda5a2a5
commit 21097bb8bd
2 changed files with 16 additions and 2 deletions

View file

@ -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):

View file

@ -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"
})
)
);