From d0890180821c67c75a5f95ab1aa677f588b1d7eb Mon Sep 17 00:00:00 2001 From: modeco80 Date: Wed, 10 Jul 2024 07:28:14 -0400 Subject: [PATCH] allow Agent.speak() to override a previous call to speak() --- msagent.js/src/agent.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/msagent.js/src/agent.ts b/msagent.js/src/agent.ts index 17fff26..a25ef44 100644 --- a/msagent.js/src/agent.ts +++ b/msagent.js/src/agent.ts @@ -265,11 +265,13 @@ export class Agent { } speak(text: string) { - if (this.wordballoonState == null) { - this.wordballoonState = new AgentWordBalloonState(this, text); - this.wordballoonState.positionUpdated(); - this.wordballoonState.show(); + if (this.wordballoonState != null) { + this.stopSpeaking(); } + + this.wordballoonState = new AgentWordBalloonState(this, text); + this.wordballoonState.positionUpdated(); + this.wordballoonState.show(); } stopSpeaking() {