It seems like part of the problem may be related to how the logic within and between your behaviors are playing out, and how this affects what states your behaviors are returning. If you can upload your .bt file here, take a screenshot of your behavior tree, and/or post your console logs, I can take a closer look at it for you.
TextToSpeechJS behaviors will return a ‘FAILED’ state if the ‘callback()’ function is not called. By having the ‘if’ statement containing the only ‘callback()’ function, it seems like the behavior will only succeed in this state by first running through with an invalid response. Then when it runs through the second time, it retains the ‘SUCCESS’ state instead or flipping back to ‘IN_PROGRESS’ after looping and is evaluated a second time.
I’m looking into this further to see if this working as designed or if this is indeed a bug.
Try setting up your code to
notepad variables as they are being defined and evaluated. Place execute scripts beteeen behaviors with ‘console.log()’ to track where behaviors fail and get stuck. This will give you an idea of where the code and behaviors may be breaking and if this is the same thing you are seeing on your end.
I recommend moving your
if statements out of the ‘Listen’ and
TextToSpeechJS behaviors. Have your
Listen behavior parse the speech and have
TextToSpeechJS create a string dynamically using variable strings (i.e
callback("Cool, I'll play " + notepad.songTitle);. This will allow you to control branching logic with ‘Switchs’ and ‘Case’ decorators and understand how your behavior trees are executing you code. This is a preference, it helps me keep isolate and track problems.