lua-users home
lua-l archive

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


Thanks, that already helped alot, but let me try to explain it by example.
I've got this function, which is callable from Lua and registers some other
callable functions:

 static int Lua_ImportSystem(lua_State *p_pCLuaState) {
   int         l_nArguments;

   l_nArguments = lua_gettop(p_pCLuaState);           // number of arguments
   if(l_nArguments == 0) {
     lua_register(p_pCLuaState, "SetGraphicsDriver",    Lua_SetGraphicsDriver);

     lua_register(p_pCLuaState, "SetGraphicsMode",      Lua_SetGraphicsMode);
     lua_register(p_pCLuaState, "Bind",                 Lua_Bind);
     lua_register(p_pCLuaState, "RegisterResourcePath",
Lua_RegisterResourcePath);
     lua_register(p_pCLuaState, "LoadWorld",            Lua_LoadWorld);
   } else {
     LogError("Lua::LoadWorld() - Error: Expected 0 arguments, got %i",
l_nArguments);
   }
   lua_pop(p_pCLuaState, l_nArguments);

   return 0;
 }

so I could execute this code

   pCLuaState = lua_open(LUA_MINSTACK);
   lua_register(m_pCLuaState, "ImportSystem" Lua_ImportSystem);

   lua_dostring("ImportSystem()\n"
                "RegisterResourcePath(\"data\\\\graphics\")\n"
                "RegisterResourcePath(\"data\\\\worlds\")\n"
                "LoadWorld(\"demo.cdt\")\n"

I thought the first call to ImportSystem() while the script runs could register
the functions the are used below.

-Markus-