user408141
user408141

Reputation:

Get the required module names for Lua

Is there a way to check what modules is required by a lua script after I loaded it?

Upvotes: 0

Views: 1355

Answers (2)

Alexander Gladysh
Alexander Gladysh

Reputation: 41393

Check out package.loaded table.

Upvotes: 2

sbk
sbk

Reputation: 9508

More of a hack than a real solution: if you control the hosting environment, you can always replace require with your version of it:

local require_original = require

function require(module)
    -- do something with the module name
    require_original(module)
end

Upvotes: 3

Related Questions