From ad48d6666abfca8124a03375de2ebd707cd0668a Mon Sep 17 00:00:00 2001 From: Juha Jeronen Date: Mon, 5 Feb 2024 00:47:14 +0200 Subject: [PATCH] fix bug: when switching talkinghead off, set character expression --- public/scripts/extensions/expressions/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/scripts/extensions/expressions/index.js b/public/scripts/extensions/expressions/index.js index cfbb87894..2f7963e0a 100644 --- a/public/scripts/extensions/expressions/index.js +++ b/public/scripts/extensions/expressions/index.js @@ -562,8 +562,14 @@ function handleImageChange() { } } } else { - imgElement.src = ''; //remove incase char doesnt have expressions - setExpression(getContext().name2, FALLBACK_EXPRESSION, true); + imgElement.src = ''; // remove in case char doesn't have expressions + + // When switching Talkinghead off, force-set the character to the last known expression, if any. + // This preserves the same expression Talkinghead had at the moment it was switched off. + const charName = getContext().name2; + const last = lastExpression[charName]; + const targetExpression = last ? last : FALLBACK_EXPRESSION; + setExpression(charName, targetExpression, true); } }