Fix condition saving the variable too soon
This commit is contained in:
parent
b25d7dd6d5
commit
16fbee7555
1 changed files with 4 additions and 5 deletions
|
@ -452,17 +452,16 @@ class Condition(object):
|
||||||
|
|
||||||
capturedVariables = result.groupdict()
|
capturedVariables = result.groupdict()
|
||||||
|
|
||||||
if ('instantMatch' in self.vars and self.vars['instantMatch']) or not r.isSpeaking():
|
|
||||||
# try to avoid setting variables for intermediate strings
|
|
||||||
for captureGroup in capturedVariables:
|
|
||||||
story.setVariableValue(captureGroup, capturedVariables[captureGroup])
|
|
||||||
|
|
||||||
if 'instantMatch' in self.vars and self.vars['instantMatch']:
|
if 'instantMatch' in self.vars and self.vars['instantMatch']:
|
||||||
story.logger.info(f"Instant match on {self.vars['regex']}, {self.vars}")
|
story.logger.info(f"Instant match on {self.vars['regex']}, {self.vars}")
|
||||||
self.logInfo = "Instant match of {}, captured {}".format(
|
self.logInfo = "Instant match of {}, captured {}".format(
|
||||||
self.vars['regex'],
|
self.vars['regex'],
|
||||||
capturedVariables
|
capturedVariables
|
||||||
)
|
)
|
||||||
|
# Set variables only when direction returns true
|
||||||
|
if capturedVariables is not None:
|
||||||
|
for captureGroup in capturedVariables:
|
||||||
|
story.setVariableValue(captureGroup, capturedVariables[captureGroup])
|
||||||
return True
|
return True
|
||||||
# TODO: implement 'instant match' -> don't wait for isFinished()
|
# TODO: implement 'instant match' -> don't wait for isFinished()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue