Giving NPC names now possible
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
<body onpageshow="load()">
|
||||
<div id="bubble">
|
||||
<p id="title"></p>
|
||||
<p id="dlg-text"></p>
|
||||
</div>
|
||||
<img hidden="true" id="triangle" src="text_horror/assets/triangle.png">
|
||||
|
@@ -9,8 +9,7 @@ function load() {
|
||||
.then(Response => Response.json())
|
||||
.then(data => {
|
||||
dlgFile = data;
|
||||
dlgLines = dlgFile;
|
||||
typeWriter();
|
||||
changeDlg("start");
|
||||
})
|
||||
}
|
||||
|
||||
@@ -30,9 +29,17 @@ function nextDlg() {
|
||||
if (document.getElementById("dlg-text").innerHTML.length == dlgLines[dlgPointer].length) { //check if text is typed out
|
||||
document.getElementById("triangle").hidden = true;
|
||||
if (dlgPointer < dlgLines.length - 1) { //check if dlgPointer is not at the array end
|
||||
do
|
||||
do {
|
||||
if (String(dlgLines[dlgPointer]).startsWith("_")) {
|
||||
switch (dlgLines[dlgPointer].split(":")[0]) {
|
||||
case "_title":
|
||||
document.getElementById("title").innerHTML = dlgLines[dlgPointer].split(':')[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
dlgPointer++;
|
||||
while (!(typeof dlgLines[dlgPointer] === 'string')) //again if it's not string
|
||||
}
|
||||
while (typeof dlgLines[dlgPointer] !== 'string' || String(dlgLines[dlgPointer]).startsWith("_")) //again if it's not string
|
||||
typeindex = 0;
|
||||
document.getElementById("dlg-text").innerHTML = "";
|
||||
typeWriter();
|
||||
@@ -40,4 +47,10 @@ function nextDlg() {
|
||||
document.getElementById("bubble").hidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeDlg(dlgKey = "") {
|
||||
var dlgPointer = 0;
|
||||
dlgLines = dlgFile[dlgKey];
|
||||
typeWriter();
|
||||
}
|
@@ -1,7 +1,10 @@
|
||||
[
|
||||
"Hello welcome to TextHorror!",
|
||||
"This is the second line",
|
||||
1,
|
||||
2,
|
||||
"Aand a third line"
|
||||
]
|
||||
{
|
||||
"start": [
|
||||
"Hello welcome to TextHorror!",
|
||||
"_title:NPC Name",
|
||||
1,
|
||||
"This is the second line",
|
||||
2,
|
||||
"Aand a third line"
|
||||
]
|
||||
}
|
@@ -7,7 +7,6 @@ body {
|
||||
color-scheme: dark;
|
||||
background-color: black;
|
||||
color: white;
|
||||
text-align: center;
|
||||
font-family: pixel-font;
|
||||
}
|
||||
|
||||
@@ -20,6 +19,13 @@ body {
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
#title {
|
||||
font-size: 30px;
|
||||
text-decoration: underline;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#dlg-text {
|
||||
text-align: left;
|
||||
font-size: 40px;
|
||||
|
Reference in New Issue
Block a user