# HG changeset patch # User Myhailo Danylenko # Date 1269984484 -10800 # Node ID 59aeae623ac6726231a97cd2838d566e4ad90394 # Parent b00f9ce82016c50db6b8bc790ea8cda546b6abd2 Allow main.connection() to fail diff -r b00f9ce82016 -r 59aeae623ac6 main.c --- a/main.c Wed Mar 31 00:12:21 2010 +0300 +++ b/main.c Wed Mar 31 00:28:04 2010 +0300 @@ -382,10 +382,13 @@ /// main.connection /// Returns lightuserdata of mcabber's loudmouth connection. /// This can be very useful with lua-loudmouth, and not much otherwise. -/// R: lightuserdata +/// R: lightuserdata or nil static int lua_main_connection (lua_State *L) { - lua_pushlightuserdata (L, lconnection); + if (xmpp_is_online ()) + lua_pushlightuserdata (L, lconnection); + else + lua_pushnil (L); return 1; } #endif