Deltarune (Chapter 3) 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
                if (nextchar == "O")
99
                {
100
                    var nextchar2var = real(nextchar2);
101
                    if (global.writerobj[nextchar2var] == obj_funnytext)
102
                        charpos += ceil(sprite_get_width(global.writerimg[nextchar2var]) / hspace);
103
                }
104
            }
105
        }
106
        else if (thischar == "&" || thischar == "\n")
107
        {
108
            if (charpos > stringmax)
109
                stringmax = charpos;
110
            remspace = -1;
111
            charpos = 0;
112
            linecount += 1;
113
            skip = 1;
114
            nextchar = string_char_at(mystring, i + 1);
115
            if (aster == 1 && autoaster == 1 && nextchar != "*" && global.lang != "ja")
116
            {
117
                charpos = 2;
118
                length += 2;
119
                mystring = string_insert("||", mystring, i + 1);
120
                i += 2;
121
            }
122
        }
123
        if (skip == 0)
124
        {
125
            if (thischar == " ")
126
            {
127
                remspace = i;
128
                remchar = charpos;
129
            }
130
            if (thischar == "*")
131
                aster = 1;
132
            if (charpos >= charline)
133
            {
134
                if (remspace > 2)
135
                {
136
                    mystring = string_delete(mystring, remspace, 1);
137
                    mystring = string_insert("&", mystring, remspace);
138
                    i = remspace + 1;
139
                    if (remchar > stringmax)
140
                        stringmax = remchar;
141
                    remspace = -1;
142
                    charpos = 1;
143
                    linecount += 1;
144
                    
scr_asterskip
scr_asterskip

function
scr_asterskip()
{ if (aster == 1 && autoaster == 1) { length += 2; mystring = string_insert("||", mystring, i); } if (aster == 2) aster = 1; }
();
145
                }
146
                else
147
                {
148
                    if (charpos > stringmax)
149
                        stringmax = charpos;
150
                    mystring = string_insert("&", mystring, i);
151
                    length += 1;
152
                    charpos = 1;
153
                    remspace = -1;
154
                    linecount += 1;
155
                    i += 1;
156
                    
scr_asterskip
scr_asterskip

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