Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_scr_text_choices

(view raw script w/o annotations or w/e)
1
function scr_text_choices
scr_text_choices

function scr_text_choices() { if (live_call()) return global.live_result; if (variable_instance_exists(id, "ch_delay")) { if (ch_delay > 0) { ch_delay--; exit; } else { ch_delay = -1; } } if (variable_instance_exists(id, "ch_alpha") && variable_instance_exists(id, "alpha_fade")) { if (variable_instance_exists(id, "alpha_fade_out") && alpha_fade_out == true) { if (ch_alpha > 0.01) { ch_alpha = lerp(ch_alpha, 0, 0.2); exit; } else { ch_alpha = 0; outcome = p; choice = false; alpha_fade_out = false; alpha_fade = false; } } else if (alpha_fade == true) { if (ch_alpha < 0.99) ch_alpha = lerp(ch_alpha, 1, 0.15); else ch_alpha = 1; if (ch_alpha < 0.75) exit; } } if (outcome == p && choice == false) { if ((message_current + 1) < array_length_1d(message)) { message_current += 1; cutoff = 0; } else { global.dialogue_open = false; } outcome = 0; } if (message_current == ch_msg) choice = true; if (choice == true && cutoff >= string_length(message[message_current])) { switch (p) { case 1: if (global.right_keyp && ch[2] != "") p = 2; if (global.down_keyp && ch[3] != "") p = 3; break; case 2: if (global.left_keyp) p = 1; if (global.down_keyp) { if (ch[4] != "") p = 4; else if (ch[3] != "") p = 3; } break; case 3: if (global.right_keyp && ch[4] != "") p = 4; if (global.up_keyp) p = 1; break; case 4: if (global.up_keyp) p = 2; if (global.left_keyp) p = 3; break; } if (ch[2] != "" && (global.right_keyp || global.down_keyp || global.up_keyp || global.left_keyp)) audio_play_sound(snd_mainmenu_select, 1, 0); if (keyboard_multicheck_pressed(0)) { if (variable_instance_exists(id, "alpha_fade") && alpha_fade == true) { alpha_fade_out = true; } ...
()
2
{
3
    if (live_call())
4
        return global.live_result;
5
    if (variable_instance_exists(id, "ch_delay"))
6
    {
7
        if (ch_delay > 0)
8
        {
9
            ch_delay--;
10
            exit;
11
        }
12
        else
13
        {
14
            ch_delay = -1;
15
        }
16
    }
17
    if (variable_instance_exists(id, "ch_alpha") && variable_instance_exists(id, "alpha_fade"))
18
    {
19
        if (variable_instance_exists(id, "alpha_fade_out") && alpha_fade_out == true)
20
        {
21
            if (ch_alpha > 0.01)
22
            {
23
                ch_alpha = lerp(ch_alpha, 0, 0.2);
24
                exit;
25
            }
26
            else
27
            {
28
                ch_alpha = 0;
29
                outcome = p;
30
                choice = false;
31
                alpha_fade_out = false;
32
                alpha_fade = false;
33
            }
34
        }
35
        else if (alpha_fade == true)
36
        {
37
            if (ch_alpha < 0.99)
38
                ch_alpha = lerp(ch_alpha, 1, 0.15);
39
            else
40
                ch_alpha = 1;
41
            if (ch_alpha < 0.75)
42
                exit;
43
        }
44
    }
45
    if (outcome == p && choice == false)
46
    {
47
        if ((message_current + 1) < array_length_1d(message))
48
        {
49
            message_current += 1;
50
            cutoff = 0;
51
        }
52
        else
53
        {
54
            global.dialogue_open = false;
55
        }
56
        outcome = 0;
57
    }
58
    if (message_current == ch_msg)
59
        choice = true;
60
    if (choice == true && cutoff >= string_length(message[message_current]))
61
    {
62
        switch (p)
63
        {
64
            case 1:
65
                if (global.right_keyp && ch[2] != "")
66
                    p = 2;
67
                if (global.down_keyp && ch[3] != "")
68
                    p = 3;
69
                break;
70
            case 2:
71
                if (global.left_keyp)
72
                    p = 1;
73
                if (global.down_keyp)
74
                {
75
                    if (ch[4] != "")
76
                        p = 4;
77
                    else if (ch[3] != "")
78
                        p = 3;
79
                }
80
                break;
81
            case 3:
82
                if (global.right_keyp && ch[4] != "")
83
                    p = 4;
84
                if (global.up_keyp)
85
                    p = 1;
86
                break;
87
            case 4:
88
                if (global.up_keyp)
89
                    p = 2;
90
                if (global.left_keyp)
91
                    p = 3;
92
                break;
93
        }
94
        if (ch[2] != "" && (global.right_keyp || global.down_keyp || global.up_keyp || global.left_keyp))
95
            audio_play_sound(snd_mainmenu_select, 1, 0);
96
        if (keyboard_multicheck_pressed(0))
97
        {
98
            if (variable_instance_exists(id, "alpha_fade") && alpha_fade == true)
99
            {
100
                alpha_fade_out = true;
101
            }
102
            else
103
            {
104
                outcome = p;
105
                choice = false;
106
            }
107
            audio_play_sound(snd_confirm, 1, 0);
108
        }
109
    }
110
}