cortomaltese_mf
New Member
- Joined
- Feb 12, 2007
- Messages
- 2 (0.00/day)
Hello there,
I use Lua script language, either calling lua scripts from C++ or calling C/C++ functions from lua. Im running lua version 5.0.2.
I'm using the require function from a C program to load lua functions
and evrything seems to work fine.
As I read,
<<require keeps a table with the names of all loaded files. If a
required file is already in the table, require simply returns. So if I
overwrite a lua file containing a function, to get the new version I
must restart the program.
As I read in the Lua manual, after a successful require"foo",
_LOADED["foo"] will not be nil. If you then assign nil to
_LOADED["foo"], a subsequent require"foo" will run the file again.>>
With this in mind, my aim was to do something like
_LOADED[funcname] = nil everytime I overwrite the file.
My problem is that I'm not able to access this table from my C
program, i.e. I do something like
lua_getglobal(L, "_LOADED");
if (!lua_istable(L, -1))
{printf"_LOADED is not a valid table"); exit(0);}
n = lua_getn(L, -1); n IS ALWAYS ZERO !!!!!!
I try to read my element in the following way:
lua_getglobal(L, "_LOADED");
if (!lua_istable(L, -1))
{printf"_LOADED is not a valid table"); exit(0);}
lua_pushstring(L, funcname);
lua_gettable(L, -2);
if (!lua_isstring(L, -1))
printf("invalid component in _LOADED");
else
myname = lua_tostring(L, -1);
lua_pop(L, 1);
But I always get the message invalid component.
I run the require function before so I expected to find something in
the _LOADED table.
Can anybody please help me to change the _LOADED[] table values from
my C program.
Thank you in advance
I use Lua script language, either calling lua scripts from C++ or calling C/C++ functions from lua. Im running lua version 5.0.2.
I'm using the require function from a C program to load lua functions
and evrything seems to work fine.
As I read,
<<require keeps a table with the names of all loaded files. If a
required file is already in the table, require simply returns. So if I
overwrite a lua file containing a function, to get the new version I
must restart the program.
As I read in the Lua manual, after a successful require"foo",
_LOADED["foo"] will not be nil. If you then assign nil to
_LOADED["foo"], a subsequent require"foo" will run the file again.>>
With this in mind, my aim was to do something like
_LOADED[funcname] = nil everytime I overwrite the file.
My problem is that I'm not able to access this table from my C
program, i.e. I do something like
lua_getglobal(L, "_LOADED");
if (!lua_istable(L, -1))
{printf"_LOADED is not a valid table"); exit(0);}
n = lua_getn(L, -1); n IS ALWAYS ZERO !!!!!!
I try to read my element in the following way:
lua_getglobal(L, "_LOADED");
if (!lua_istable(L, -1))
{printf"_LOADED is not a valid table"); exit(0);}
lua_pushstring(L, funcname);
lua_gettable(L, -2);
if (!lua_isstring(L, -1))
printf("invalid component in _LOADED");
else
myname = lua_tostring(L, -1);
lua_pop(L, 1);
But I always get the message invalid component.
I run the require function before so I expected to find something in
the _LOADED table.
Can anybody please help me to change the _LOADED[] table values from
my C program.
Thank you in advance