Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_mc_cart_Step_0

(view raw script w/o annotations or w/e)
1
if live_call()
2
    return global.live_result;
3
while place_meeting(x, y, obj_pl)
4
    obj_pl.y -= 1
5
if minecart_empty
6
{
7
    if audio_is_playing(minecart_sound)
8
        audio_stop_sound(minecart_sound)
9
    if (sprite_index == drain_sprite && image_index >= (image_number - 1))
10
        image_speed = 0
11
    return;
12
}
13
if (abs(minecart_vsp + minecart_hsp) == 0 && keyboard_multicheck_pressed(0) && scr_interact
scr_interact

function scr_interact() //gml_Script_scr_interact { if (distance_to_object(obj_pl) < 20 && obj_pl.state == gml_Script_scr_normal_state) { var pl_dir = obj_pl.direction var pl_x = 0 var pl_y = 0 var check_distance_x = 0 var check_distance_y = 0 switch pl_dir { case 0: pl_x = obj_pl.bbox_right pl_y = obj_pl.bbox_top + 1 check_distance_x = 20 break case 180: pl_x = obj_pl.bbox_left pl_y = obj_pl.bbox_top + 1 check_distance_x = -20 break case 90: pl_x = obj_pl.x pl_y = obj_pl.bbox_top check_distance_y = -20 break case 270: pl_x = obj_pl.x pl_y = obj_pl.bbox_bottom check_distance_y = 20 break } if collision_line_first(pl_x, pl_y, (pl_x + check_distance_x), (pl_y + check_distance_y), id, false, false) return true; } }
())
14
{
15
    minecart_base_speed = 2
16
    minecart_start = true
17
    minecart_sound = audio_play_sound(snd_rock_roll, 1, 1)
18
    if (minecart_direction == "down")
19
        minecart_vsp = 1
20
    if (minecart_direction == "up")
21
        minecart_vsp = -1
22
    if (minecart_direction == "right")
23
        minecart_hsp = 1
24
    if (minecart_direction == "left")
25
        minecart_hsp = -1
26
}
27
var x_check = x
28
var y_check = y
29
if (minecart_hsp > 0)
30
    x_check = bbox_left
31
if (minecart_hsp < 0)
32
    x_check = bbox_right
33
if (minecart_vsp > 0)
34
    y_check = bbox_top
35
if (minecart_vsp < 0)
36
    y_check = bbox_bottom
37
if (position_meeting(x_check, y_check, obj_tracks_parent) && track_id == noone)
38
{
39
    track_id = instance_position(x_check, y_check, obj_tracks_parent)
40
    show_debug_message(track_id.rotation)
41
    switch track_id.rotation
42
    {
43
        case "top-right":
44
            if (minecart_hsp == -1)
45
            {
46
                minecart_vsp = 1
47
                minecart_hsp = 0
48
            }
49
            else if (minecart_vsp == -1)
50
            {
51
                minecart_vsp = 0
52
                minecart_hsp = 1
53
            }
54
            else
55
            {
56
                minecart_vsp *= -1
57
                minecart_hsp *= -1
58
            }
59
            break
60
        case "top-left":
61
            if (minecart_hsp == 1)
62
            {
63
                minecart_vsp = 1
64
                minecart_hsp = 0
65
            }
66
            else if (minecart_vsp == -1)
67
            {
68
                minecart_vsp = 0
69
                minecart_hsp = -1
70
            }
71
            else
72
            {
73
                minecart_vsp *= -1
74
                minecart_hsp *= -1
75
            }
76
            break
77
        case "bottom-right":
78
            if (minecart_hsp == -1)
79
            {
80
                minecart_vsp = -1
81
                minecart_hsp = 0
82
            }
83
            else if (minecart_vsp == 1)
84
            {
85
                minecart_vsp = 0
86
                minecart_hsp = 1
87
            }
88
            else
89
            {
90
                minecart_vsp *= -1
91
                minecart_hsp *= -1
92
            }
93
            break
94
        case "bottom-left":
95
            if (minecart_hsp == 1)
96
            {
97
                minecart_vsp = -1
98
                minecart_hsp = 0
99
            }
100
            else if (minecart_vsp == 1)
101
            {
102
                minecart_vsp = 0
103
                minecart_hsp = -1
104
            }
105
            else
106
            {
107
                minecart_vsp *= -1
108
                minecart_hsp *= -1
109
            }
110
            break
111
        case "horizontal":
112
            if (abs(minecart_vsp) >= 1)
113
            {
114
                minecart_vsp *= -1
115
                minecart_hsp *= -1
116
            }
117
            break
118
        case "vertical":
119
            if (abs(minecart_hsp) >= 1)
120
            {
121
                minecart_vsp *= -1
122
                minecart_hsp *= -1
123
            }
124
            break
125
    }
126
127
    if (abs(minecart_hsp) > 0)
128
        y = track_id.y + 6
129
    if (abs(minecart_vsp) > 0)
130
        x = track_id.x + 10
131
}
132
if (position_meeting(x_check, y_check, obj_mc_rail_barrier) && track_id == noone)
133
{
134
    track_id = instance_position(x_check, y_check, obj_mc_rail_barrier)
135
    minecart_vsp *= -1
136
    minecart_hsp *= -1
137
}
138
var colliding_cart = instance_position((x_check + sign(minecart_hsp) * sprite_width), (y_check + sign(minecart_vsp) * sprite_height), obj_mc_cart)
139
if (colliding_cart != id && colliding_cart != noone && track_id == noone)
140
{
141
    track_id = colliding_cart
142
    minecart_vsp *= -1
143
    minecart_hsp *= -1
144
}
145
if (track_id != noone && (!(position_meeting(x_check, y_check, track_id))))
146
    track_id = -4
147
if (position_meeting(x_check, y_check, obj_mc_rail_bumper) && (!minecart_start))
148
{
149
    minecart_start = true
150
    minecart_hsp = 0
151
    minecart_vsp = 0
152
    audio_play_sound(snd_rock_break, 1, 0)
153
    var bumper = instance_position(x_check, y_check, obj_mc_rail_bumper)
154
    minecart_direction = bumper.minecart_direction
155
}
156
if (position_meeting(x_check, y_check, obj_mc_pressure_pad) && (!minecart_start))
157
{
158
    bumper = instance_position(x_check, y_check, obj_mc_pressure_pad)
159
    if (bumper.cart_color == cart_color)
160
    {
161
        minecart_start = true
162
        minecart_vsp = 0
163
        minecart_hsp = 0
164
        minecart_direction = "up"
165
        audio_play_sound(snd_rock_break, 1, 0)
166
        x = bumper.x
167
        y = bumper.y - 6
168
        bumper.image_speed = 0.2
169
        minecart_empty = true
170
        alarm[1] = 20
alarm[1]

if live_call() return global.live_result; sprite_index = drain_sprite image_speed = 0.3 obj_mc_puzzle_controller.puzzle_count += 1
171
        audio_play_sound(snd_minecart_puzzle_drain, 1, 0)
172
    }
173
    else if (track_id == -4)
174
    {
175
        track_id = bumper
176
        audio_play_sound(snd_fail, 1, 0)
177
        minecart_vsp *= -1
178
        minecart_hsp *= -1
179
    }
180
}
181
if ((!(place_meeting(x_check, y_check, obj_mc_rail_bumper))) && (!(place_meeting(x_check, y_check, obj_mc_pressure_pad))))
182
    minecart_start = false
183
if (abs(minecart_hsp) > 0)
184
    sprite_index = side_sprite
185
if (abs(minecart_vsp) > 0)
186
    sprite_index = forward_sprite
187
if (abs(minecart_hsp) > 0 || abs(minecart_vsp) > 0)
188
    image_speed = 0.2
189
else
190
{
191
    image_speed = 0
192
    image_index = 0
193
    if audio_is_playing(minecart_sound)
194
        audio_stop_sound(minecart_sound)
195
}
196
x += (minecart_hsp * minecart_base_speed)
197
y += (minecart_vsp * minecart_base_speed)
198
depth = (-y)