Repository navigation
Expand file tree
/
Copy pathScriptSearcher.lua
More file actions
194 lines (169 loc) · 4.2 KB
/
Copy pathScriptSearcher.lua
File metadata and controls
194 lines (169 loc) · 4.2 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
type Data = {
Script: BaseScript,
Path: string,
Selectable: unknown?,
SelectableObject: unknown?
}
type Scripts = {[number]: Data}
local BLACKLISTED_PATHS = {
workspace,
game:GetService("Players"),
game:GetService("StarterGui"),
game:GetService("CorePackages"),
game:GetService("CoreGui"),
}
--// Studio stuff
decompile = decompile or function() return "" end
cloneref = cloneref or function(...) return ... end
local Scripts = {} :: Scripts
local UpdateList
local CurrentSearch = ""
local CurrentSelectable = nil
local Index = 0
local function ParentAllowed(Script: BaseScript): boolean
for _, Parent in next, BLACKLISTED_PATHS do
if Script:IsDescendantOf(Parent) then
return false
end
end
return true
end
local function IsAllowed(Script)
if not (Script:IsA("BaseScript") or Script:IsA("ModuleScript")) then return end
if not ParentAllowed(Script) then return end
if not Script then return end
return true
end
local function AddScript(Script)
if not Script then return end
local Success, Clone = pcall(Script.Clone, Script)
if not Success then return end
--// Allowed?
if not IsAllowed(Script) or not Clone then
if Clone then Clone:Destroy() end
return
end
if Clone:IsA("BaseScript") then
Clone.Enabled = false
end
local Data = {
Script = Clone,
Path = Script:GetFullName()
}
table.insert(Scripts, Data)
--// Update UI
if UpdateList then
UpdateList(Data)
end
end
--// Cloneref parents
for Index, Parent in next, BLACKLISTED_PATHS do
BLACKLISTED_PATHS[Index] = cloneref(Parent)
end
--// Collection
for _, Script in game:GetDescendants() do
AddScript(Script)
end
game.DescendantAdded:Connect(AddScript)
--// Until loaded
repeat wait() until game:IsLoaded()
local ReGui = loadstring(game:HttpGet('https://raw.githubusercontent.com/depthso/Dear-ReGui/refs/heads/main/ReGui.lua'))()
--// Window
local Window = ReGui:Window({
Size = UDim2.fromOffset(600, 250),
NoScroll = true,
Title = "Script search | Depso"
}):Center()
local Layout = Window:List({
UiPadding = 2,
VerticalFlex = Enum.UIFlexAlignment.Fill,
FillDirection = Enum.FillDirection.Vertical,
Size = UDim2.fromScale(1, 1)
})
--// List
local ListLayout = Layout:Canvas({
FillDirection = Enum.FillDirection.Vertical,
Size = UDim2.new(0.45, 0, 1, 0),
UiPadding = 2,
Fill = true
})
local Search = ListLayout:InputText({
Size = UDim2.new(1, 0, 0, 20),
Label = "",
Value = "",
Placeholder = "Search..."
})
local List = ListLayout:Canvas({
Scroll = true,
UiPadding = 0,
AutomaticSize = Enum.AutomaticSize.None,
FlexMode = Enum.UIFlexMode.None,
Fill = true
})
--// Editor
local EditorLayout = Layout:Canvas({
FillDirection = Enum.FillDirection.Vertical,
Size = UDim2.new(0.55, 0, 1, 0),
UiPadding = 2,
Fill = true
})
local Thing = EditorLayout:CodeEditor({
Text = "print('oh this cool')",
Fill = true,
})
local Row = EditorLayout:Row()
Row:Button({
Text = "Copy",
Callback = function()
setclipboard(Thing:GetText())
end,
})
--// Search functionality
local function SetVisible(Script: Data)
local Path = Script.Path:lower()
local Selectable = Script.SelectableObject
if not Selectable then return end
Selectable.Visible = Path:find(CurrentSearch) and true
end
Search.Callback = function(_, Input: string)
CurrentSearch = Input:lower()
for _, Script in next, Scripts do
SetVisible(Script)
end
end
--// Scripts
local function ViewScript(Data: Data)
--// Update selectables
local Selectable = Data.Selectable
Selectable:SetSelected(true)
if CurrentSelectable then
CurrentSelectable:SetSelected(false)
end
CurrentSelectable = Selectable
--// Decompile
local Decompiled = decompile(Data.Script)
local Source = `-- {Data.Path}\n{Decompiled}`
Thing:SetText(Source)
end
local function UpdateList(Data: Data)
--// Lazy loading
Index += 1
if Index > 20 then
Index = 0
task.wait()
end
--// Selectable
local Selectable, Object = List:Selectable({
Text = Data.Path:sub(1, 100),
Callback = function()
ViewScript(Data)
end,
})
--// Set visible
Data.SelectableObject = Object
Data.Selectable = Selectable
SetVisible(Data)
end
for _, Script in next, Scripts do
UpdateList(Script)
end