made more than just string types work

This commit is contained in:
Yannik
2023-05-26 18:40:10 +02:00
parent c286d2489f
commit 9a99b9ab03
2 changed files with 5 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
var speed = 50; var speed = 50;
var typeindex = 0; var typeindex = 0;
var dlgFile = {}; var dlgFile = {};
var dlgLines = [""]; let dlgLines;
var dlgPointer = 0; var dlgPointer = 0;
function load() { function load() {
@@ -15,15 +15,15 @@ function load() {
} }
function typeWriter() { function typeWriter() {
if (document.getElementById("bubble").innerHTML.length - 1 < dlgLines[dlgPointer].length) { if (document.getElementById("bubble").innerHTML.length - 1 < dlgLines[dlgPointer].toString().length) {
document.getElementById("bubble").innerHTML += dlgLines[dlgPointer].charAt(typeindex); document.getElementById("bubble").innerHTML += dlgLines[dlgPointer].toString().charAt(typeindex);
typeindex++; typeindex++;
setTimeout(typeWriter, speed);//loops because of running "typeWriter" after waiting setTimeout(typeWriter, speed);//loops because of running "typeWriter" after waiting
} }
} }
function mouseClick() { function mouseClick() {
if (document.getElementById("bubble").innerHTML.length == dlgLines[dlgPointer].length) { if (document.getElementById("bubble").innerHTML.length == dlgLines[dlgPointer].toString().length) {
if (dlgPointer < dlgLines.length - 1) { if (dlgPointer < dlgLines.length - 1) {
dlgPointer++; dlgPointer++;
typeindex = 0; typeindex = 0;

View File

@@ -1,5 +1,6 @@
[ [
"Hello welcome to TextHorror!", "Hello welcome to TextHorror!",
"This is the second line", "This is the second line",
1,
"Aand a third line" "Aand a third line"
] ]