Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update init.lua #491

Merged
merged 3 commits into from
Sep 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 41 additions & 24 deletions MainModule/Server/Dependencies/Loadstring/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
Credit to Stravant for LBI.

Credit to the creators of all the other modules used in this.
(Yueliang is made by Kein-Hong Man, FiOne by Rerumu)

Sceleratis was here and decided modify some things.

einsteinK was here again to fix a bug in LBI for if-statements

Github@ccuser44(ALE111_boiPNG) was here to to make some small changes (made it use vanilla loadstring when possible)
--]]

local waitDeps = {
'FiOne';
'LuaK';
'LuaP';
'LuaU';
'LuaX';
'LuaY';
'LuaZ';
"FiOne";
"LuaK";
"LuaP";
"LuaU";
"LuaX";
"LuaY";
"LuaZ";
}

for i,v in pairs(waitDeps) do script:WaitForChild(v) end
for _, v in ipairs(waitDeps) do
script:WaitForChild(v)
end

local luaX = require(script.LuaX)
local luaY = require(script.LuaY)
Expand All @@ -32,22 +37,34 @@ local LuaState = {}

getfenv().script = nil

return function(str,env)
local f,writer,buff,name
local env = env or getfenv(2)
local name = (env.script and env.script:GetFullName())
local ran,error = pcall(function()
local zio = luaZ:init(luaZ:make_getS(str), nil)
if not zio then return error() end
local func = luaY:parser(LuaState, zio, nil, name or "::Adonis::Loadstring::")
writer, buff = luaU:make_setS()
luaU:dump(LuaState, func, writer, buff)
f = fiOne(buff.data, env)
end)

if ran then
return f,buff.data
local isLoadstringEnabled = pcall(loadstring, "local a = 5 local c = a + 1")

return function(str, env)
local f, writer, buff, name, error, success

if isLoadstringEnabled then
success, error = pcall(function()
f = loadstring(str)
setfenv(f, env)
end)
else
local env = env or getfenv(2)
local name = (env.script and env.script:GetFullName())
success, error = pcall(function()
local zio = luaZ:init(luaZ:make_getS(str), nil)
if not zio then
return error()
end
local func = luaY:parser(LuaState, zio, nil, name or "::Adonis::Loadstring::")
writer, buff = luaU:make_setS()
luaU:dump(LuaState, func, writer, buff)
f = fiOne(buff.data, env)
end)
end

if success then
return f, (buff and buff.data)
else
return nil,error
return nil, error
end
end