Undertale script viewer

← back to main script listing

gml_Script_scr_gettext

(view raw script w/o annotations or w/e)
1
var text_id = argument[0];
2
var text = ds_map_find_value(global.text_data_en, text_id);
3
if (is_undefined(text))
4
    text = "";
5
if (global.language == "ja")
6
{
7
    var loc_text = ds_map_find_value(global.text_data_ja, text_id);
8
    if (!is_undefined(loc_text))
9
        text = loc_text;
10
}
11
for (var i = 1; i <= (string_length(text) - 3); i++)
12
{
13
    if (string_copy(text, i, 2) == "\[" && string_char_at(text, i + 3) == "]")
14
    {
15
        var sel = string_char_at(text, i + 2);
16
        var replace;
17
        if (sel == "C")
18
            replace = global.charname;
19
        else if (sel == "G")
20
            replace = string(global.gold);
21
        else if (sel == "I")
22
            replace = global.itemname[global.menucoord[1]];
23
        else if (sel == "1" && argument_count > 1)
24
            replace = argument[1];
25
        else if (sel == "2" && argument_count > 2)
26
            replace = argument[2];
27
        else if (sel == "3" && argument_count > 3)
28
            replace = argument[3];
29
        else if (sel == "4" && argument_count > 4)
30
            replace = argument[4];
31
        else if (sel == "5" && argument_count > 5)
32
            replace = argument[5];
33
        else if (sel == "6" && argument_count > 6)
34
            replace = argument[6];
35
        else if (sel == "7" && argument_count > 7)
36
            replace = argument[7];
37
        else if (sel == "8" && argument_count > 8)
38
            replace = argument[8];
39
        else if (sel == "9" && argument_count > 9)
40
            replace = argument[9];
41
        else
42
            replace = "";
43
        var before = string_copy(text, 1, i - 1);
44
        var after = string_copy(text, i + 4, string_length(text));
45
        text = before + replace + after;
46
        i += (string_length(replace) - 1);
47
    }
48
}
49
return text;