-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeltaAddons.lua
209 lines (186 loc) · 8.49 KB
/
deltaAddons.lua
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
repeat task.wait() until game:IsLoaded() -- precaution
--[[ Variables ]]--
local specialInfo = {
MeshPart = { "PhysicsData", "InitialSize" },
UnionOperation = { "AssetId", "ChildData", "FormFactor", "InitialSize", "MeshData", "PhysicsData" },
Terrain = { "SmoothGrid", "MaterialColors" },
};
local renv = getrenv();
local genv = getgenv();
local _getreg = clonefunction(getreg);
local _gettenv = clonefunction(gettenv);
local _getinfo = clonefunction(debug.getinfo);
local _gethiddenproperty = clonefunction(gethiddenproperty);
local _getconnections = clonefunction(getconnections);
local _getsenv = clonefunction(getsenv);
local _newcclosure = clonefunction(newcclosure);
local _getthreadidentity = clonefunction(getthreadidentity);
local _setthreadidentity = clonefunction(setthreadidentity);
local _setreadonly = clonefunction(setreadonly);
local _isreadonly = clonefunction(isreadonly);
local _assert = clonefunction(renv.assert);
local _type = clonefunction(renv.type);
local _typeof = clonefunction(renv.typeof);
local _stringformat = clonefunction(renv.string.format);
local _setmetatable = clonefunction(renv.setmetatable);
local _rawset = clonefunction(renv.rawset);
local _getfenv = clonefunction(renv.getfenv);
local _setfenv = clonefunction(renv.setfenv);
--[[ Functions ]]--
genv.getallthreads = _newcclosure(function()
local threads = {};
for i, v in _getreg() do
if _type(v) == "thread" then
threads[#threads + 1] = v;
end
end
return threads;
end);
genv.getcurrentline = _newcclosure(function(level)
_assert(level == nil or _type(level) == "number", "invalid argument #1 to 'getcurrentline' (number or nil expected)");
return _getinfo((level or 0) + 3).currentline;
end);
genv.getscriptenvs = _newcclosure(function()
local envs = {};
for i, v in _getreg() do
if _type(v) == "thread" then
local env = _gettenv(v);
local scr = env.script;
if scr and envs[scr] == nil then
envs[scr] = env;
end
end
end
return envs;
end);
genv.getspecialinfo = _newcclosure(function(inst)
local classInfo = _assert(_typeof(inst) == "Instance" and specialInfo[inst.ClassName], "invalid argument #1 to 'getspecialinfo' (MeshPart or UnionOperation or Terrain expected)");
local instInfo = {};
for i, v in classInfo do
instInfo[v] = _gethiddenproperty(inst, v);
end
return instInfo;
end);
genv.firesignal = _newcclosure(function(signal, ...)
_assert(_typeof(signal) == "RBXScriptSignal", _stringformat("invalid argument #1 to 'firesignal' (RBXScriptSignal expected, got %s)", _typeof(signal)));
for _, v in _getconnections(signal) do
v:Fire(...);
end
end);
genv.emulate_call = _newcclosure(function(func, targetScript, ...)
_assert(_typeof(func) == "function", _stringformat("invalid argument #1 to 'emulate_call' (function expected, got %s)", _typeof(func)));
_assert(_typeof(targetScript) == "Instance" and (targetScript.ClassName == "LocalScript" or targetScript.ClassName == "ModuleScript"), "invalid argument #2 to 'emulate_call' (LocalScript or ModuleScript expected)");
local scriptEnv = _getsenv(targetScript);
local env = _setmetatable({}, {
__index = _newcclosure(function(self, idx)
return scriptEnv[idx];
end),
__newindex = _newcclosure(function(self, idx, newval)
_rawset(self, idx, newval);
end),
__metatable = "This metatable is locked."
});
return (_newcclosure(function(...)
local realEnv = _getfenv(1);
local oldIdentity = _getthreadidentity();
_setthreadidentity(2);
_setfenv(1, env);
local ret = func(...);
_setfenv(1, realEnv);
_setthreadidentity(oldIdentity);
return ret;
end))(...);
end);
genv.makereadonly = _newcclosure(function(table)
_assert(_typeof(table) == "table", _stringformat("invalid argument #1 to 'makereadonly' (table expected, got %s)", _typeof(table)));
return _setreadonly(table, true);
end);
genv.makewriteable = _newcclosure(function(table)
_assert(_typeof(table) == "table", _stringformat("invalid argument #1 to 'makewriteable' (table expected, got %s)", _typeof(table)));
return _setreadonly(table, false);
end);
genv.iswriteable = _newcclosure(function(table)
_assert(_typeof(table) == "table", _stringformat("invalid argument #1 to 'iswriteable' (table expected, got %s)", _typeof(table)));
return not _isreadonly(table);
end);
genv.getmodules = clonefunction(getloadedmodules);
local debug_is_readonly = _isreadonly(genv.debug);
_setreadonly(genv.debug, false)
genv.debug.validlevel = genv.debug.isvalidlevel
_setreadonly(genv.debug, debug_is_readonly)
genv.rconsoleshow = _newcclosure(function() end);
genv.rconsolename = _newcclosure(function() end);
genv.rconsoleinput = _newcclosure(function() return "" end);
genv.rconsoleprint = _newcclosure(function() end);
genv.rconsolewarn = _newcclosure(function() end);
genv.rconsoleerror = _newcclosure(function() end);
genv.rconsoleinfo = _newcclosure(function() end);
--[[ Aliases ]]--
local aliasData = {
--[getclipboard] = { "fromclipboard" },
--[executeclipboard] = { "execclipboard" },
[setclipboard] = { "setrbxclipboard", "toclipboard" },
[hookfunction] = { "hookfunc", "replaceclosure", "replacefunction", "replacefunc", "detourfunction", "replacecclosure", "detour_function" },
--[isfunctionhooked] = { "ishooked" },
--[restorefunction] = { "restorefunc", "restoreclosure" },
[clonefunction] = { "clonefunc" },
[makewriteable] = { "make_writeable" },
[makereadonly] = { "make_readonly" },
[getinstances] = { "get_instances" },
[getscripts] = { "get_scripts" },
[getmodules] = { "get_modules" },
[getloadedmodules] = { "get_loaded_modules" },
[getnilinstances] = { "get_nil_instances" },
[getcallingscript] = { "get_calling_script", "getscriptcaller", "getcaller" },
[getallthreads] = { "get_all_threads" },
[getgc] = { "get_gc_objects" },
[gettenv] = { "getstateenv" },
[getnamecallmethod] = { "get_namecall_method" },
[setnamecallmethod] = { "set_namecall_method" },
[debug.getupvalue] = { "getupvalue" },
[debug.getupvalues] = { "getupvalues" },
[debug.setupvalue] = { "setupvalue" },
[debug.getconstant] = { "getconstant" },
[debug.getconstants] = { "getconstants" },
[debug.setconstant] = { "setconstant" },
[debug.getproto] = { "getproto" },
[debug.getprotos] = { "getprotos" },
[debug.getstack] = { "getstack" },
[debug.setstack] = { "setstack" },
[debug.getinfo] = { "getinfo" },
[debug.validlevel] = { "validlevel", "isvalidlevel" },
[islclosure] = { "is_l_closure" },
[iscclosure] = { "is_c_closure" },
[isourclosure] = { "isexecutorclosure", "is_our_closure", "is_executor_closure", "is_krnl_closure", "is_fluxus_closure", "isfluxusclosure", "is_fluxus_function", "isfluxusfunction", "is_protosmasher_closure","checkclosure", "issynapsefunction", "is_synapse_function" },
[getscriptclosure] = { "getscriptfunction", "get_script_function" },
[getscriptbytecode] = { "dumpstring" },
[emulate_call] = { "secure_call", "securecall" },
[queueonteleport] = { "queue_on_teleport" },
--[clearteleportqueue] = { "clear_teleport_queue" },
[request] = { "http_request" },
[getsenv] = { "getmenv" },
[getfpscap] = { "get_fps_cap" },
[identifyexecutor] = { "getexecutorname" },
[getcustomasset] = { "getsynasset" },
[base64_encode] = { "base64encode" },
[base64_decode] = { "base64decode" },
[isrbxactive] = { "isgameactive", "iswindowactive" },
[delfile] = { "deletefile" },
[delfolder] = { "deletefolder" },
[getthreadidentity] = { "getidentity", "getcontext", "getthreadcontext", "get_thread_context", "get_thread_identity" },
[setthreadidentity] = { "setidentity", "setcontext", "setthreadcontext", "set_thread_context", "set_thread_identity" },
[iswriteable] = { "iswritable" },
[makewriteable] = { "makewritable" },
[rconsoleshow] = { "rconsolecreate", "consolecreate" },
[rconsolename] = { "consolesettitle" },
[rconsoleinput] = { "consoleinput" },
[rconsoleprint] = { "logprint", "consoleprint", "printuiconsole", "printdebug" },
[rconsolewarn] = { "logwarn", "consolewarn", "warnuiconsole", "printuiwarn" },
[rconsoleerror] = { "logerror", "consoleerror", "erroruiconsole", "printuierror", "rconsoleerr", "consoleerr" },
[rconsoleinfo] = { "loginfo", "consoleinfo", "infouiconsole" }
};
for func, aliases in aliasData do
for idx = 1, #aliases do
genv[aliases[idx]] = func;
end
end