Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
67 lines (56 loc) · 1.74 KB
/
Copy pathindex.js
File metadata and controls
67 lines (56 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
if (!("parse" in Array.prototype)) {
Object.defineProperty(Array.prototype, "parse", {
enumerable: false,
value: function () {
var o, i, ln = this.length;
while (ln--) {
i = Math.random() * (ln + 1) | 0;
o = this[ln];
this[ln] = this[i];
this[i] = o;
}
return this;
}
});
}
function cutStringAtChar(string = "", char) {
for (const key in string)
if (string[key] == char)
return string.substring(0, key)
}
function cutStringAtCharReverse(string = "", char = '') {
for (let key = string.length; key != 0; key--)
if (string[key] == char)
return string.substring(++key, string.length)
return string
}
function parseImage(pointer = "", index) {
const { $ref } = pointer;
let obj = require(cutStringAtChar($ref[index], '#'));
const splits = cutStringAtCharReverse($ref[index], "#").split('/');
for (const s of splits)
obj = obj[s];
return obj;
}
var IF = require("./interface.js")
var story = require("./story.json")
function followStory(index) {
if (index === undefined) return
for (const part in story[index].dialogue) {
if (story[index].dialogue[part] == null) return;
if (part != story[index].dialogue.length - 1) {
IF.showScreenDialogue(
story[index].namebox[part],
story[index].dialogue[part],
parseImage(story[index].screen, part)
)
}
}
followStory(story[index].continue_at[IF.showScreenQuestion(
story[index].namebox[story[index].namebox.length - 1],
story[index].options,
parseImage(story[index].screen, story[index].namebox.length - 1),
story[index].dialogue[story[index].dialogue.length - 1]
)])
}
followStory("1")