Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function iTable(cpTable,newTable,func)
- for k,v in pairs(cpTable) do
- if type(v)=="table" then
- newTable[k]={}
- iTable(v,newTable[k],func)
- else
- newTable[k]=func
- end
- end
- return newTable
- end
- local function blocked(...)
- error("Blocked function!",2)
- end
- local function getFunc(f)
- if fs.exists(f) then
- fu=fs.open(f,"r")
- funct=fu.readAll()
- fu.close()
- funct=loadstring(funct)
- return funct
- else
- end
- end
- function setEnvironment(sfunc,blockedFuncs,bFunc)
- if sfunc==nil then
- error("Must be 2 arguments")
- end
- bErr=bFunc or blocked
- if type(sfunc)=="string" then
- func=getFunc(sfunc)
- elseif type(sfunc)=="function" then
- func=sfunc
- end
- local env=setmetatable({},{__index=_G})
- local nBlocked=iTable(blockedFuncs,env,bErr)
- setfenv(func,nBlocked)
- func()
- end
Advertisement
Add Comment
Please, Sign In to add comment