lua-users home
lua-l archive

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


>void my_dostring(lua_State *L, const char *cmd)
>{
>    int status = luaL_loadbuffer(L, cmd, strlen(cmd), cmd);
>
>    if (status == 0)
>        status = lua_pcall(L, 0, LUA_MULTRET, 0);
>
>    if (status != 0)
>    {
>        lua_getglobal(L, "_ALERT");
>        lua_insert(L, -2);
>        lua_call(L, 1, 0);
>    }
>}

Just note that calling _ALERT on errors in now a protocol implemented in
lauxlib not in the core nor in lua.c, and it's there for compatibility only.
In other words, you don't *have* to call _ALERT on errors. The official protocol
for handling errors is that lua_load leaves error messages on the stack and
lua_pcall can receive an error handling function as its last argument.
--lhf