Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_writer_Other_15

(view raw script w/o annotations or w/e)
1
if (formatted == 0)
2
{
3
    length = string_length(mystring);
4
    charpos = -1;
5
    remspace = -1;
6
    remchar = -1;
7
    linecount = 0;
8
    stringmax = 0;
9
    aster = 0;
10
    for (i = 0; i < (length + 1); i += 1)
11
    {
12
        skip = 0;
13
        thischar = string_char_at(mystring, i);
14
        if (thischar == "`")
15
        {
16
            i++;
17
        }
18
        else if (thischar == "/" || thischar == "%")
19
        {
20
            if (charpos > -1)
21
                charpos -= 1;
22
        }
23
        else if (thischar == "^")
24
        {
25
            if (charpos > -1)
26
                charpos -= 2;
27
        }
28
        else if (thischar == "\\")
29
        {
30
            if (charpos > -1)
31
                charpos -= 3;
32
            if (dialoguer == 1)
33
            {
34
                nextchar = string_char_at(mystring, i + 1);
35
                nextchar2 = string_char_at(mystring, i + 2);
36
                if (nextchar == "E")
37
                {
38
                    __nextface = ord(nextchar2);
39
                    if (__nextface >= 48 && __nextface <= 57)
40
                        global.fe = real(nextchar2);
41
                    else if (__nextface >= 65 && __nextface <= 90)
42
                        global.fe = __nextface - 55;
43
                    else if (__nextface >= 97 && __nextface <= 122)
44
                        global.fe = __nextface - 61;
45
                }
46
                if (nextchar == "F")
47
                {
48
                    if (nextchar2 == "0")
49
                        global.fc = 0;
50
                    if (nextchar2 == "S")
51
                        global.fc = 1;
52
                    if (nextchar2 == "R")
53
                        global.fc = 2;
54
                    if (nextchar2 == "N")
55
                        global.fc = 3;
56
                    if (nextchar2 == "T")
57
                        global.fc = 4;
58
                    if (nextchar2 == "L")
59
                        global.fc = 5;
60
                    if (nextchar2 == "s")
61
                        global.fc = 6;
62
                    if (nextchar2 == "U")
63
                        global.fc = 9;
64
                    if (nextchar2 == "A")
65
                        global.fc = 10;
66
                    if (nextchar2 == "a")
67
                        global.fc = 11;
68
                    if (nextchar2 == "B")
69
                        global.fc = 12;
70
                    if (nextchar2 == "r")
71
                        global.fc = 15;
72
                    if (nextchar2 == "u")
73
                        global.fc = 18;
74
                    if (nextchar2 == "K")
75
                        global.fc = 20;
76
                    if (nextchar2 == "Q")
77
                        global.fc = 21;
78
                    if (global.fc == 0)
79
                    {
80
                        charline = originalcharline;
81
                        writingx = x;
82
                    }
83
                    else
84
                    {
85
                        charline = 26;
86
                        writingx = x + (58 * f);
87
                        if (global.lang == "ja")
88
                            writingx -= 8;
89
                    }
90
                }
91
                if (nextchar == "m")
92
                    drawaster = 0;
93
                if (nextchar == "s")
94
                {
95
                    if (nextchar2 == "0")
96
                        skippable = 0;
97
                }
98
            }
99
        }
100
        else if (thischar == "&" || thischar == "\n")
101
        {
102
            if (charpos > stringmax)
103
                stringmax = charpos;
104
            remspace = -1;
105
            charpos = 0;
106
            linecount += 1;
107
            skip = 1;
108
            nextchar = string_char_at(mystring, i + 1);
109
            if (aster == 1 && autoaster == 1 && nextchar != "*" && global.lang != "ja")
110
            {
111
                charpos = 2;
112
                length += 2;
113
                mystring = string_insert("||", mystring, i + 1);
114
                i += 2;
115
            }
116
        }
117
        if (skip == 0)
118
        {
119
            if (thischar == " ")
120
            {
121
                remspace = i;
122
                remchar = charpos;
123
            }
124
            if (thischar == "*")
125
                aster = 1;
126
            if (charpos >= charline)
127
            {
128
                if (remspace > 2)
129
                {
130
                    mystring = string_delete(mystring, remspace, 1);
131
                    mystring = string_insert("&", mystring, remspace);
132
                    i = remspace + 1;
133
                    if (remchar > stringmax)
134
                        stringmax = remchar;
135
                    remspace = -1;
136
                    charpos = 1;
137
                    linecount += 1;
138
                    
scr_asterskip
scr_asterskip

function
scr_asterskip()
{ if (aster == 1 && autoaster == 1) { length += 2; mystring = string_insert("||", mystring, i); } if (aster == 2) aster = 1; }
();
139
                }
140
                else
141
                {
142
                    if (charpos > stringmax)
143
                        stringmax = charpos;
144
                    mystring = string_insert("&", mystring, i);
145
                    length += 1;
146
                    charpos = 1;
147
                    remspace = -1;
148
                    linecount += 1;
149
                    i += 1;
150
                    
scr_asterskip
scr_asterskip

function
scr_asterskip()
{ if (aster == 1 && autoaster == 1) { length += 2; mystring = string_insert("||", mystring, i); } if (aster == 2) aster = 1; }
();
151
                }
152
            }
153
            else
154
            {
155
                charpos += 1;
156
            }
157
        }
158
    }
159
    if (autocenter == 1)
160
    {
161
        x = ((camerax() + (camerawidth() / 2)) - ((stringmax * hspace) / 2)) + 5;
162
        y = (cameray() + (cameraheight() / 2)) - ((writingy + ((linecount + 1) * vspace)) / 2) - 10;
163
    }
164
    if (charpos > stringmax)
165
        stringmax = charpos;
166
    formatted = 1;
167
}