Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_phone_controls_Step_1

(view raw script w/o annotations or w/e)
1
touch_current = 0
2
phn_down = false
3
phn_left = false
4
phn_up = false
5
phn_right = false
6
phn_downp = false
7
phn_leftp = false
8
phn_upp = false
9
phn_rightp = false
10
var i = 0
11
while (i < 4)
12
{
13
    var mouse_xx = device_mouse_x_to_gui(i)
14
    var mouse_yy = device_mouse_y_to_gui(i)
15
    a_pressed = (point_in_circle(mouse_xx, mouse_yy, mobile_a_xx, mobile_a_yy, button_radius) && device_mouse_check_button(i, mb_any))
16
    if (a_pressed && (!noloop_a))
17
    {
18
        noloop_a = i
19
        keyboard_key_press(vk_return)
20
    }
21
    if ((!a_pressed) && noloop_a == i)
22
    {
23
        noloop_a = -1
24
        keyboard_key_release(vk_return)
25
    }
26
    if a_pressed
27
        break
28
    else
29
    {
30
        i++
31
        continue
32
    }
33
}
34
i = 0
35
while (i < 4)
36
{
37
    mouse_xx = device_mouse_x_to_gui(i)
38
    mouse_yy = device_mouse_y_to_gui(i)
39
    b_pressed = (point_in_circle(mouse_xx, mouse_yy, mobile_b_xx, mobile_b_yy, button_radius) && device_mouse_check_button(i, mb_any))
40
    if (b_pressed && (!noloop_b))
41
    {
42
        noloop_b = i
43
        keyboard_key_press(vk_shift)
44
    }
45
    if ((!b_pressed) && noloop_b == i)
46
    {
47
        noloop_b = -1
48
        keyboard_key_release(vk_shift)
49
    }
50
    if b_pressed
51
        break
52
    else
53
    {
54
        i++
55
        continue
56
    }
57
}
58
i = 0
59
while (i < 4)
60
{
61
    mouse_xx = device_mouse_x_to_gui(i)
62
    mouse_yy = device_mouse_y_to_gui(i)
63
    y_pressed = (point_in_circle(mouse_xx, mouse_yy, mobile_a_xx, mobile_y_yy, button_radius) && device_mouse_check_button(i, mb_any))
64
    if (y_pressed && (!noloop_y))
65
    {
66
        noloop_y = i
67
        keyboard_key_press(vk_control)
68
    }
69
    if ((!y_pressed) && noloop_y == i)
70
    {
71
        noloop_y = -1
72
        keyboard_key_release(vk_control)
73
    }
74
    if y_pressed
75
        break
76
    else
77
    {
78
        i++
79
        continue
80
    }
81
}
82
var stick_radius = sprite_get_width(spr_andrd_stick_base) * button_scale
83
i = 0
84
while (i < 4)
85
{
86
    mouse_xx = device_mouse_x_to_gui(i)
87
    mouse_yy = device_mouse_y_to_gui(i)
88
    if (mouse_xx <= 0 && device_mouse_check_button(i, mb_any) && stick_movement_active == false)
89
    {
90
        mobile_stick_xx = mouse_xx
91
        mobile_stick_yy = mouse_yy
92
        stick_movement_active = true
93
    }
94
    if (stick_movement_active == true)
95
    {
96
        mobile_stick_dir = point_direction(mobile_stick_xx, mobile_stick_yy, mouse_xx, mouse_yy)
97
        mobile_stick_distance = clamp(point_distance(mobile_stick_xx, mobile_stick_yy, mouse_xx, mouse_yy), 0, (sprite_get_width(spr_andrd_stick) * 0.5 * button_scale))
98
        stick_x_dist = lengthdir_x(mobile_stick_distance, mobile_stick_dir)
99
        stick_y_dist = lengthdir_y(mobile_stick_distance, mobile_stick_dir)
100
        if (!(device_mouse_check_button(i, mb_any)))
101
            stick_movement_active = false
102
        if (mobile_stick_xx < ((-stick_radius) * 0.5))
103
            stick_alpha = lerp(stick_alpha, 1, 0.25)
104
        else
105
            stick_alpha = lerp(stick_alpha, 0.15, 0.25)
106
        if (mobile_stick_distance > (global.gamepad_deadzone * stick_radius))
107
        {
108
            var dgn = 20
109
            if (mobile_stick_dir >= (45 - dgn) && mobile_stick_dir < (135 + dgn))
110
            {
111
                if (stick_noloop_v != 1)
112
                {
113
                    phn_upp = true
114
                    stick_noloop_v = 1
115
                }
116
                phn_up = true
117
            }
118
            if (mobile_stick_dir >= (135 - dgn) && mobile_stick_dir < (225 + dgn))
119
            {
120
                if (stick_noloop_h != 1)
121
                {
122
                    phn_leftp = true
123
                    stick_noloop_h = 1
124
                }
125
                phn_left = true
126
            }
127
            if (mobile_stick_dir >= (225 - dgn) && mobile_stick_dir < (315 + dgn))
128
            {
129
                if (stick_noloop_v != 2)
130
                {
131
                    phn_downp = true
132
                    stick_noloop_v = 2
133
                }
134
                phn_down = true
135
            }
136
            if ((mobile_stick_dir >= (315 - dgn) && mobile_stick_dir <= 360) || mobile_stick_dir < (45 + dgn))
137
            {
138
                if (stick_noloop_h != 2)
139
                {
140
                    phn_rightp = true
141
                    stick_noloop_h = 2
142
                }
143
                phn_right = true
144
            }
145
        }
146
        else
147
        {
148
            stick_noloop_h = 0
149
            stick_noloop_v = 0
150
        }
151
        break
152
    }
153
    else
154
    {
155
        stick_x_dist = 0
156
        stick_y_dist = 0
157
        stick_alpha = lerp(stick_alpha, 0.25, 0.25)
158
        stick_noloop_h = 0
159
        stick_noloop_v = 0
160
        i++
161
        continue
162
    }
163
}