Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_anim_custom_Create_0

(view raw script w/o annotations or w/e)
1
target_obj = -4;
2
event_handler = -4;
3
anim_active = false;
4
anim_timestamps = [];
5
anim_modifier = 30;
6
anim_index = 0;
7
anim_timer = 0;
8
anim_events = [];
9
10
init = function(arg0, arg1, arg2, arg3 = 30)
11
{
12
    target_obj = arg0;
13
    target_obj.sprite_index = arg1;
14
    target_obj.image_index = 0;
15
    target_obj.image_speed = 0;
16
    anim_timestamps = arg2;
17
    anim_modifier = arg3;
18
    anim_timer = anim_timestamps[anim_index] / anim_modifier;
19
};
20
21
start = function()
22
{
23
    anim_active = true;
24
};
25
26
stop = function()
27
{
28
    anim_active = false;
29
    trigger_event("anim_end");
30
};
31
32
trigger_event = function(arg0, arg1 = -1)
33
{
34
    for (var i = 0; i < array_length(anim_events); i++)
35
    {
36
        var _event = anim_events[i][0];
37
        var _callback = anim_events[i][1];
38
        var _condition = anim_events[i][2];
39
        var _args = anim_events[i][3];
40
        if (_event == arg0)
41
        {
42
            if (_condition == arg1)
43
            {
44
                if (array_length(_args) == 0)
45
                    _callback();
46
                else if (array_length(_args) == 1)
47
                    _callback(_args[0]);
48
                else if (array_length(_args) == 2)
49
                    _callback(_args[0], _args[1]);
50
                else if (array_length(_args) == 3)
51
                    _callback(_args[0], _args[1], _args[2]);
52
            }
53
        }
54
    }
55
};
56
57
reset = function()
58
{
59
    target_obj = -4;
60
    anim_active = false;
61
    anim_timestamps = [];
62
    anim_modifier = 30;
63
    anim_index = 0;
64
    anim_timer = 0;
65
    anim_events = [];
66
};
67
68
is_playing = function()
69
{
70
    return anim_active;
71
};
72
73
anim_event = function(arg0, arg1, arg2, arg3)
74
{
75
    var event = [];
76
    event[0] = arg0;
77
    event[1] = arg1;
78
    event[2] = arg2;
79
    event[3] = arg3;
80
    return event;
81
};
82
83
event_connect = function(arg0, arg1, arg2 = -1, arg3 = [])
84
{
85
    var _event = anim_event(arg0, arg1, arg2, arg3);
86
    anim_events[array_length(anim_events)] = _event;
87
};