[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: detect if the current file is the main file ?
- From: Jamie Webb <j@...>
- Date: Mon, 15 May 2006 12:49:58 +0100
On Sun, May 14, 2006 at 09:36:26PM +0200, Mildred wrote:
> I know in python it is possible to detect if a file is used as a module
> or used as the main programm. And if it is run as the main programm run
> a main function.
> Is it possible to do the same with lua ? I tried with some
> debug functions without success.
Check the stack height at the top of your file and set a flag. When
using the 'lua' binary, you're at the top level iff debug.getinfo(3)
-- Jamie Webb