Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript_tile_layer_find

(view raw script w/o annotations or w/e)
1
function tile_layer_find(argument0, argument1, argument2) //gml_Script_tile_layer_find
2
{
3
    var __depth = argument0
4
    var __x = argument1
5
    var __y = argument2
6
    var __layers = layer_get_all()
7
    var __numlayers = array_length_1d(__layers)
8
    for (var __i = 0; __i < __numlayers; __i++)
9
    {
10
        if (layer_get_depth(__layers[__i]) != __depth)
11
        {
12
        }
13
        else
14
        {
15
            var __els = layer_get_all_elements(__layers[__i])
16
            var __numels = array_length_1d(__els)
17
            for (var __j = 0; __j < __numels; __j++)
18
            {
19
                var __eltype = layer_get_element_type(__els[__j])
20
                if (__eltype == 7)
21
                {
22
                    var __tileXscale = layer_tile_get_xscale(__els[__j])
23
                    var __tileYscale = layer_tile_get_yscale(__els[__j])
24
                    if (__tileXscale >= 0 && __tileYscale >= 0)
25
                    {
26
                        var __tileX = layer_tile_get_x(__els[__j])
27
                        if (__x < __tileX)
28
                        {
29
                        }
30
                        else
31
                        {
32
                            var __tileY = layer_tile_get_y(__els[__j])
33
                            if (__y < __tileY)
34
                            {
35
                            }
36
                            else
37
                            {
38
                                var __tileReg = layer_tile_get_region(__els[__j])
39
                                var __tileRight = __tileX + __tileXscale * __tileReg[2]
40
                                if (__x >= __tileRight)
41
                                {
42
                                }
43
                                else
44
                                {
45
                                    var __tileBottom = __tileY + __tileYscale * __tileReg[3]
46
                                    if (__y >= __tileBottom)
47
                                    {
48
                                    }
49
                                    else
50
                                        return __els[__j];
51
                                }
52
                            }
53
                        }
54
                    }
55
                    else
56
                    {
57
                        __tileReg = layer_tile_get_region(__els[__j])
58
                        var __minx = layer_tile_get_x(__els[__j])
59
                        var __maxx = __minx + __tileXscale * __tileReg[2]
60
                        if (__minx > __maxx)
61
                        {
62
                            var __temp = __minx
63
                            __minx = __maxx
64
                            __maxx = __temp
65
                        }
66
                        if (__x < __minx)
67
                        {
68
                        }
69
                        else if (__x >= __maxx)
70
                        {
71
                        }
72
                        else
73
                        {
74
                            var __miny = layer_tile_get_y(__els[__j])
75
                            var __maxy = __miny + __tileYscale * __tileReg[3]
76
                            if (__miny > __maxy)
77
                            {
78
                                __temp = __miny
79
                                __miny = __maxy
80
                                __maxy = __temp
81
                            }
82
                            if (__y < __miny)
83
                            {
84
                            }
85
                            else if (__y >= __maxy)
86
                            {
87
                            }
88
                            else
89
                                return __els[__j];
90
                        }
91
                    }
92
                }
93
            }
94
        }
95
    }
96
    return -1;
97
}