From: Sadrul Habib Chowdhury Date: Tue, 9 Jun 2009 20:59:28 +0000 (-0400) Subject: The script decides what value to return to the script system. X-Git-Url: https://repo.or.cz/w/screen-lua.git/commitdiff_plain/ace0a3fd6e98fb50e038a792eabd3faae13ec166 The script decides what value to return to the script system. It might be of interest to let several callback functions to excute for the same event. This change will be necessary for that. --- diff --git a/src/lua.c b/src/lua.c index e963c3c..0fa4c06 100644 --- a/src/lua.c +++ b/src/lua.c @@ -814,20 +814,22 @@ static int LuaDispatch(void *handler, const char *params, va_list va) { const char *func = handler; - int argc; + int argc, retvalue; lua_getfield(L, LUA_GLOBALSINDEX, func); if (lua_isnil(L, -1)) return 0; argc = LuaPushParams(L, params, va); - if (lua_pcall(L, argc, 0, 0) == LUA_ERRRUN && lua_isstring(L, -1)) + if (lua_pcall(L, argc, 1, 0) == LUA_ERRRUN && lua_isstring(L, -1)) { StackDump(L, "After LuaDispatch\n"); LuaShowErr(L); return 0; } - return 0; + retvalue = lua_tonumber(L, -1); + lua_pop(L, 1); + return retvalue; } int LuaForeWindowChanged(void)