File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -46,17 +46,23 @@ local function lines_from(file)
4646end
4747
4848local function load_chunk (content , chunkName , environment )
49- if _VERSION == " Lua 5.1 " then
49+ if type ( loadstring ) == " function " then
5050 local func , err = loadstring (content , chunkName )
5151 if not func then
5252 return nil , err
5353 end
54- if environment then
54+ if environment and type ( setfenv ) == " function " then
5555 setfenv (func , environment )
56+ elseif environment and type (load ) == " function" then
57+ return load (content , chunkName , " t" , environment )
5658 end
5759 return func
5860 end
5961
62+ if type (load ) ~= " function" then
63+ return nil , " No load function available"
64+ end
65+
6066 return load (content , chunkName , " t" , environment )
6167end
6268
You can’t perform that action at this time.
0 commit comments