lua-users home
lua-l archive

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


In my case it is mostly anonymous. I call the script from C by lua_pcall.

I checked the arg variable and it is nil. I am reading things about debug.getinfo now, but I found nothing about anonymous calls...

2009/11/6 steve donovan <steve.j.donovan@gmail.com>
On Fri, Nov 6, 2009 at 2:46 PM, Nevin Flanagan <Alestane@comcast.net> wrote:
> If you have access to the debug library inside your Lua environment,
> debug.getinfo contains a function that you can use to retrieve information
> like what name the function was called from.

This is true, but the 'function' (or rather, chunk) which is executed
when your script runs is anonymous.

However, the arg table is always available if your code runs as a
script. The caveat is that this applies to the Lua executable itself;
it may not make sense in an embedded environment (but then you could
set a helpful global)

For plain Lua, arg[-1] is the path of the Lua executable, arg[0] is
the script (path included, maybe) and arg[1]...arg[#arg] are the
command-line arguments.

steve d.



--
God$ g++ -o earth earth.cpp -O3 -lanimals -lplants -lvirus

http://fog.neopages.org/