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