[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: standalone modules
- From: Rici Lake <lua@...>
- Date: Mon, 11 Jun 2007 20:40:18 -0500
On 11-Jun-07, at 7:40 PM, Francisco Sant'anna wrote:
When creating a module sometimes is also useful to run it from the
command line as a standalone application.
How to discover the invoke method?
Here's how I'm doing now:
-- checks if the module is being 'required' or executed
local STANDALONE = (debug.getinfo(1).short_src == (arg and arg))
module ((...) or 'default_name')
if STANDALONE then
You can use the following:
local STANDALONE = type(package.loaded[...]) ~= "userdata"
There's an explanation of how it works in this message: