mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
set_emotion is not supported by old talkinghead versions
This commit is contained in:
@ -1109,22 +1109,28 @@ async function setExpression(character, expression, force) {
|
|||||||
document.getElementById('expression-holder').style.display = '';
|
document.getElementById('expression-holder').style.display = '';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
talkingHeadCheck().then(result => {
|
|
||||||
if (result) {
|
|
||||||
// Set the talkinghead emotion to the specified expression
|
// Set the talkinghead emotion to the specified expression
|
||||||
// TODO: For now, talkinghead emote only supported when VN mode is off; see also updateVisualNovelMode.
|
// TODO: For now, talkinghead emote only supported when VN mode is off; see also updateVisualNovelMode.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
let result = await talkingHeadCheck();
|
||||||
|
if (result) {
|
||||||
const url = new URL(getApiUrl());
|
const url = new URL(getApiUrl());
|
||||||
url.pathname = '/api/talkinghead/set_emotion';
|
url.pathname = '/api/talkinghead/set_emotion';
|
||||||
doExtrasFetch(url, {
|
await doExtrasFetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ emotion_name: expression }),
|
body: JSON.stringify({ emotion_name: expression }),
|
||||||
})
|
});
|
||||||
.then(response => {
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
// `set_emotion` is not present in old versions, so let it 404.
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Find the <img> element with id="expression-image" and class="expression"
|
// Find the <img> element with id="expression-image" and class="expression"
|
||||||
const imgElement = document.querySelector('img#expression-image.expression');
|
const imgElement = document.querySelector('img#expression-image.expression');
|
||||||
//console.log("searching");
|
//console.log("searching");
|
||||||
@ -1132,16 +1138,10 @@ async function setExpression(character, expression, force) {
|
|||||||
//console.log("setting value");
|
//console.log("setting value");
|
||||||
imgElement.src = getApiUrl() + '/api/talkinghead/result_feed';
|
imgElement.src = getApiUrl() + '/api/talkinghead/result_feed';
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.catch(error => {
|
catch (error) {
|
||||||
console.error(error);
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
//console.log("The fetch failed!");
|
//console.log("The fetch failed!");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user