Hello.
I have wrote a small library "vom" for LUA. The interpreter works
fine:
--begin output --
Lua 5.1.1 Copyright (C) 1994-2006 Lua.org, PUC-Rio
require "vom"
print(vom.getloop())
25
-- end output --
Now, I want to call the function "vom.getloop()" from the API, but I
don't have any results. I try this:
-- begin source --
LUASTATE init(void) {
//lua_State *L = lua_open();
lua_State *L = luaL_newstate();
printf("L:%d\n",L);
luaL_openlibs(L);
luaL_dofile(L,"testlib.lua");
return L;
}
double get_counter(LUASTATE L) {
double tmp;
lua_getglobal(L,"vom.getloop");
lua_pushnil(L);
lua_resume(L,1);
tmp = lua_tonumber(L,-1);
printf("Error:%s",lua_tostring(L,-2));
return tmp;
}
-- end source--
At first I make a "init" and load the "testlib.lua", because here
is the
the require "vom" integrated.
The error message is:
Error:attempt to call a nil value
It is possible to call the function "vom.getloop()" directly from the
API, in this case from the C-Function "get_counter" ???
THX
Marc