Undertale Yellow script viewer

← back to main script listing

gml_GlobalScript___background_get_element

(view raw script w/o annotations or w/e)
1
var __result;
2
function __background_get_element(argument0) //gml_Script___background_get_element
3
{
4
    var __bind = argument0
5
    __result[0] = -1
6
    __result[1] = -1
7
    __result[2] = -1
8
    var __fgstring = "Compatibility_Foreground_"
9
    var __bgstring = "Compatibility_Background_"
10
    var __fglen = string_length(__fgstring)
11
    var __bglen = string_length(__bgstring)
12
    var __layerlist = layer_get_all()
13
    var __layerlistlength = array_length_1d(__layerlist)
14
    var __layerid = -1
15
    var __isforeground = false
16
    var __i = 0
17
    while (__i < __layerlistlength)
18
    {
19
        var __layername = layer_get_name(__layerlist[__i])
20
        if (string_pos(__fgstring, __layername) > 0)
21
        {
22
            var __slotchr = string_char_at(__layername, (__fglen + 1))
23
            if (__slotchr == "")
24
            {
25
                __i++
26
                continue
27
            }
28
            else
29
            {
30
                var __slot = real(__slotchr)
31
                if (__slot == __bind)
32
                {
33
                    __layerid = __layerlist[__i]
34
                    __isforeground = true
35
                    break
36
                }
37
                else
38
                {
39
                    __i++
40
                    continue
41
                }
42
            }
43
        }
44
        else if (string_pos(__bgstring, __layername) > 0)
45
        {
46
            __slotchr = string_char_at(__layername, (__bglen + 1))
47
            if (__slotchr == "")
48
            {
49
                __i++
50
                continue
51
            }
52
            else
53
            {
54
                __slot = real(__slotchr)
55
                if (__slot == __bind)
56
                {
57
                    __layerid = __layerlist[__i]
58
                    __isforeground = false
59
                    break
60
                }
61
                else
62
                {
63
                    __i++
64
                    continue
65
                }
66
            }
67
        }
68
        else
69
        {
70
            __i++
71
            continue
72
        }
73
    }
74
    if (__layerid != -1)
75
    {
76
        var __els = layer_get_all_elements(__layerid)
77
        var __elslength = array_length_1d(__els)
78
        for (__i = 0; __i < __elslength; __i++)
79
        {
80
            if (layer_get_element_type(__els[__i]) == 1)
81
            {
82
                __result[0] = __els[__i]
83
                __result[1] = __layerid
84
                __result[2] = __isforeground
85
            }
86
        }
87
    }
88
    else
89
    {
90
        var __newback = __background_set_element(__bind, false, false, -1, 0, 0, true, true, 1, 1, false, 0, 0, c_white, 1)
91
        __result[0] = __newback[0]
92
        __result[1] = __newback[1]
93
        __result[2] = false
94
    }
95
    return __result;
96
}