Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
-- This file:
-- http://angg.twu.net/LATEX/lualoader.lua.html
-- http://angg.twu.net/LATEX/lualoader.lua
--  (find-angg        "LATEX/lualoader.lua")
-- See: (find-es "luatex" "require")
--      http://tug.org/pipermail/luatex/2015-February/005073.html
-- Usage:
--   \directlua{dofile "lualoader.lua"}

package.loaders = package.loaders or package.searchers
loadstring = loadstring or load

-- From http://lua-users.org/wiki/LuaModulesLoader
local function lualoader(modulename)
  local errmsg = ""
  -- Find source
  local modulepath = string.gsub(modulename, "%.", "/")
  for path in string.gmatch(package.path, "([^;]+)") do
    local filename = string.gsub(path, "%?", modulepath)
    local file = io.open(filename, "rb")
    if file then
      -- Compile and return the module
      return assert(loadstring(assert(file:read("*a")), filename))
    end
    errmsg = errmsg.."\n\tno file '"..filename.."' (checked with custom loader)"
  end
  return errmsg
end

-- See http://www.lua.org/manual/5.1/manual.html#pdf-package.loaders
table.insert(package.loaders, 2, lualoader)

-- See also: http://lua-users.org/wiki/BinaryModulesLoader