This repository was archived by the owner on Apr 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGenerator.lua
More file actions
31 lines (27 loc) · 1.98 KB
/
Generator.lua
File metadata and controls
31 lines (27 loc) · 1.98 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
local SG = {};
--// https://github.com/strawbberrys/LuaScripts/blob/main/TableDumper.lua
local type = type local pairs = pairs local tostring = tostring local string_rep = string.rep local table_concat = table.concat local function DumpTable(Table, IndentAmount) local IndentAmount, TableAmount, Amount = IndentAmount or 1, 0, 0 local Indent = string_rep(" ", IndentAmount) for Index in pairs(Table) do TableAmount = TableAmount + 1 end local TableDump, Ending = {((TableAmount > 0 and "{\n") or "{")}, (((IndentAmount > 1 and TableAmount > 0) and "},\n") or "}") for Index, Value in pairs(Table) do local ValueType = type(Value) Amount = Amount + 1 local FixedValue = ((ValueType == "string" or ValueType == "function") and "\"" .. tostring(Value) .. "\"" or tostring(Value)) local Data = ((ValueType ~= "table" and "[\"" .. tostring(Index) .. "\"] = " .. FixedValue or "[\"" .. tostring(Index) .. "\"] = " .. DumpTable(Value, IndentAmount + 1))) local Key = Indent .. ((ValueType ~= "table" and Data .. ((Amount ~= TableAmount and ",\n") or "")) or Data) TableDump[#TableDump + 1] = Key end TableDump[#TableDump + 1] = ((TableAmount > 0 and "\n") or "") .. (((IndentAmount > 1 and TableAmount > 0) and string_rep(" ", IndentAmount - 1) .. Ending or Ending .. ((TableAmount == 0 and ",\n") or ""))) return table_concat(TableDump) end
SG.Copy = function(...)
if (cenv.Copy == false) then
return;
end;
return setclipboard(...);
end;
SG.Generate = function(vl,mode)
local Code = ([=[
--Code generated by cenv
local Function;
local Consts = %s;
for i,v in next,getgc(true) do
if (type(v) == 'function' and islclosure(v) and not is_synapse_function(v)) then
for i2,v2 in next,Consts do
if table.find(debug.getconstants(v),v2) then
Function = v;
end;
end;
end;
end;]=]):format(DumpTable(vl));
if (mode == 2) then Code = Code:gsub('Consts','Ups'); Code = Code:gsub('getconstants','getupvalues'); end;
return Code;
end;
return SG;