-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathScriptScanner.lua
More file actions
50 lines (43 loc) · 1.28 KB
/
Copy pathScriptScanner.lua
File metadata and controls
50 lines (43 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
local ScriptScanner = {}
local LocalScript = import("objects/LocalScript")
local getGc = getGc or get_gc_objects
local getSenv = getsenv
local getProtos = getprotos
local getConstants = getconstants
local getScriptClosure = getscriptclosure
local isXClosure = isXClosure
local getfenv = getfenv
local rawget = rawget
local type = type
local pairs = pairs
local typeof = typeof
local requiredMethods = {
["getGc"] = true,
["getSenv"] = true,
["getProtos"] = true,
["getConstants"] = true,
["getScriptClosure"] = true,
["isXClosure"] = true
}
local function scan(query)
local scripts = {}
query = query or ""
for _i, v in pairs(getGc()) do
if type(v) == "function" and not isXClosure(v) then
local script = rawget(getfenv(v), "script")
if typeof(script) == "Instance" and
not scripts[script] and
script:IsA("LocalScript") and
script.Name:lower():find(query) and
getScriptClosure(script) and
pcall(function() getsenv(script) end)
then
scripts[script] = LocalScript.new(script)
end
end
end
return scripts
end
ScriptScanner.RequiredMethods = requiredMethods
ScriptScanner.Scan = scan
return ScriptScanner