Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_train_station_Step_2

(view raw script w/o annotations or w/e)
1
if (pressed == 0)
2
{
3
    var _waiting = false;
4
    with (obj_traintrack_moving_parent)
5
    {
6
        if (con != 0)
7
            _waiting = true;
8
    }
9
    if (!_waiting && place_meeting(x, y, obj_homealone_heart))
10
        pressed = 1;
11
}
12
else if (pressed == 1)
13
{
14
    snd_play_pitch(snd_noise, 1.2);
15
    obj_homealone_heart.x = heartx;
16
    obj_homealone_heart.y = hearty;
17
    holdheart = true;
18
    hearttimer = 5;
19
    pressed = 2;
20
    debug_message("hold");
21
}
22
else if (pressed == -1)
23
{
24
    snd_play_pitch(snd_noise, 0.8);
25
    pressed = 0;
26
}
27
else if (pressed == 2)
28
{
29
    var _waiting = false;
30
    with (obj_traintrack_moving_parent)
31
    {
32
        if (con != 0)
33
            _waiting = true;
34
    }
35
    if (!_waiting && !heartontrain && !place_meeting(x, y, obj_homealone_heart))
36
        pressed = -1;
37
}
38
if (pressed == 0)
39
    image_index = 0;
40
else
41
    image_index = 1;
42
if (hearttimer > 0)
43
    hearttimer--;
44
if (holdheart)
45
{
46
    obj_homealone_heart.freeze = 1;
47
    if (!heartontrain)
48
    {
49
        if (hearttimer == 0 && (left_p() || right_p() || up_p() || down_p()))
50
        {
51
            obj_homealone_heart.freeze = 0;
52
            holdheart = false;
53
        }
54
    }
55
}
56
var _traincarriage = instance_position(center_x, center_y, obj_train_piece_carriage);
57
if (_traincarriage != -4 && (_traincarriage.train_index == 1 || _traincarriage.train_index == 2))
58
{
59
    if (hearttimer == 0 && point_distance(_traincarriage.x, _traincarriage.y, center_x, center_y) < 3)
60
    {
61
        if (_traincarriage.controller.heartontrain)
62
        {
63
            _traincarriage.controller.heartontrain = false;
64
            heartontrain = false;
65
            holdheart = true;
66
            obj_homealone_heart.x = heartx;
67
            obj_homealone_heart.y = hearty;
68
            hearttimer = 10;
69
            debug_message("off train");
70
        }
71
        else if (holdheart && _traincarriage.controller.active)
72
        {
73
            _traincarriage.controller.heartontrain = true;
74
            heartontrain = true;
75
            hearttimer = 15;
76
            holdheart = false;
77
            debug_message("onto train");
78
        }
79
    }
80
}