lua-users home
lua-l archive

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

Thanks Nevin for pointing out, found it! Although it seems to be a bad solution...

local da= debug.getinfo(1,"S")
print (da.source)

The da.source returns the path to the script!

Because I dont know if it is fast enough to be called each frame, since they say that the debug information is stored with velocity as a second goal. But I will find it soon enough, it is very practical though, but if this not work I will try pushing and setting a global...

hey steve, that would be a better solution, but why my print(arg) returns nil? Ok, maybe I have not passed any arguments, but do I have to pass args in order to access the arg[0]??

2009/11/6 steve donovan <>
On Fri, Nov 6, 2009 at 3:06 PM, steve donovan <> wrote:
> On Fri, Nov 6, 2009 at 2:59 PM, zweifel <> wrote:
>> I checked the arg variable and it is nil. I am reading things about
>> debug.getinfo now, but I found nothing about anonymous calls...

This illustrates the situation with pure Lua, applies to C API as well.

Lua 5.1.2  Copyright (C) 1994-2007, PUC-Rio
> ls = loadstring 'print(...)'
> = ls
function: 0x807d490    --> compiled chunk (won't have a name)
> pcall(ls,10)      --> call with arg, prints it out
> pcall(ls,'one','two')
one     two

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