Stary2001

require

Mar 23rd, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. local shell
  2. function setShell(s)
  3. shell=s
  4. _G.require.setShell=nil
  5. end
  6.  
  7. function require(path)
  8. if _G[path]~=nil then return end -- stuff
  9.  
  10. local modulePath=shell.resolve(".")
  11. for part in string.gmatch(path,"[^%.]+") do
  12. local can = modulePath.."/"..part
  13. if fs.exists(can) then
  14. modulePath=can
  15. elseif fs.exists(can..".lua") then
  16. modulePath=can..".lua"
  17. end
  18. end
  19. if modulePath == shell.resolve(".") then
  20. return nil
  21. else
  22. return loadfile(modulePath)()
  23. end
  24. end
Advertisement
Add Comment
Please, Sign In to add comment