lua-users home
lua-l archive

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


I want to substitude the load_lua function witch my loader, and then i can control the process, such as loading lua file from packed files.
i do it like this:

lua_getfield(l, LUA_GLOBALSINDEX, LUA_LOADLIBNAME);
lua_pushstring(l, "loaders");
lua_gettable(l, -2);

lua_pushnumber(l, 2);
lua_pushcfunction(l, my_loader); // set my loader
lua_settable(l, -3);

my loader:

int __cdecl my_module_loader(lua_State* l)
{
        const char *name = luaL_checkstring(l, 1);
        lua_getfield(l, LUA_ENVIRONINDEX, "path"); ---------------------> here, i want to get the path value. but i got null.
        const char* temp1 = lua_tostring(l, -1);          ---------------------> temp1  == NULL
        printf("load module");
        return 1;
}

i want to get the path value. but i got null in my loader.
i compare my loader with de loader_lua, there is no difference between them. but in loader_lua it works.

so, i was comfused by this.