voice update

This commit is contained in:
Yannik
2023-06-21 13:57:00 +02:00
parent 22b9a22119
commit a31fccce66
3 changed files with 13 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ var skipDlg = false;
var answers;
var keys;
var allowNextDlg = true;
var voice;
function load() {
fetch("text_horror/dialogue.json") //Load json file here
@@ -31,7 +32,6 @@ function changeDlg(dlgKey) {
}
function updateDlg() {
console.log(dlgLines[dlgPointer]);
typeindex = 0;
document.getElementById("dlg-text").innerHTML = "";
document.getElementById("triangle").hidden = true;
@@ -41,6 +41,10 @@ function updateDlg() {
function typeWriter() {
if (typeindex < dlgLines[dlgPointer].length) {
document.getElementById("dlg-text").innerHTML += dlgLines[dlgPointer].charAt(typeindex);
if (voice != null && typeindex % 3 == 1) {
voice.load();
voice.play();
}
typeindex++;
setTimeout(typeWriter, speed);
} else if (allowNextDlg)
@@ -65,6 +69,13 @@ function nextDlg(dlgPointerIncrease = true) {
document.getElementById("title").innerHTML = dlgLines[dlgPointer].split(':')[1];
nextDlg();
}
if (dlgLines[dlgPointer].split(":")[0] === "_voice") {
if (dlgLines[dlgPointer].split(':')[1].length != 0)
voice = new Audio("text_horror/assets/voices/" + dlgLines[dlgPointer].split(':')[1] + ".wav");
else
voice = null;
nextDlg();
}
} else
updateDlg();
}

Binary file not shown.

View File

@@ -15,6 +15,7 @@
],
"Also Yes": [
"_title:Spitzkopf",
"_voice:spitzkopf",
"That was a weird answer... Is anything wrong with you?",
{
"Yes my name is Peter": [