26 lines
671 B
Lua
26 lines
671 B
Lua
local function loader(mn)
|
|
local at=nil
|
|
if fs.exists("/lib/"..mn..".lua") then
|
|
at="/lib/"..mn..".lua"
|
|
elseif fs.exists(shell.dir().."/lib/"..mn..".lua") then
|
|
at=shell.dir().."/lib/"..mn..".lua"
|
|
end
|
|
if at then
|
|
local e=getfenv(1)
|
|
if e.package and #e.package.loaders==2 then
|
|
table.insert(e.package.loaders,loader)
|
|
end
|
|
return loadfile(at,nil,e)
|
|
end
|
|
return false,"\t\tno file '/lib/"..mn..".lua\n\t\tno file '"..shell.dir().."/lib/"..mn..".lua"
|
|
end
|
|
|
|
local osrun=_G.os.run
|
|
function _G.os.run(e,p,...)
|
|
if e.package and #e.package.loaders==2 then
|
|
table.insert(e.package.loaders,loader)
|
|
end
|
|
return osrun(e,p,...)
|
|
end
|
|
shell.setPath(shell.path()..":/bin")
|