lua-users home
lua-l archive

Re: Auto-detecting whether script is stand-alone or module?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Jan 4, 2013 at 3:39 AM, Patrick <patrick@spellingbeewinnars.org> wrote:
> What about arg[0], that should be the scripts name
That works very nicely for detecting whether a file was loaded as a
module or a function in my experience.
Something like:
-- module.lua
...
if arg[0]:match 'module%.lua$' then
 ... we are a program...
end
steve d.

AltStyle によって変換されたページ (->オリジナル) /