summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_client.cpp18
-rw-r--r--src/script/lua_api/l_client.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp
index 7cb89188d..5f9474702 100644
--- a/src/script/lua_api/l_client.cpp
+++ b/src/script/lua_api/l_client.cpp
@@ -25,8 +25,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gettext.h"
#include "l_internal.h"
#include "lua_api/l_item.h"
+#include "mainmenumanager.h"
#include "util/string.h"
+extern MainGameCallback *g_gamecallback;
+
int ModApiClient::l_get_current_modname(lua_State *L)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
@@ -107,6 +110,20 @@ int ModApiClient::l_send_respawn(lua_State *L)
return 0;
}
+// disconnect()
+int ModApiClient::l_disconnect(lua_State *L)
+{
+ // Stops badly written Lua code form causing boot loops
+ if (getClient(L)->isShutdown()) {
+ lua_pushboolean(L, false);
+ return 1;
+ }
+
+ g_gamecallback->disconnect();
+ lua_pushboolean(L, true);
+ return 1;
+}
+
// gettext(text)
int ModApiClient::l_gettext(lua_State *L)
{
@@ -178,4 +195,5 @@ void ModApiClient::Initialize(lua_State *L, int top)
API_FCT(get_node);
API_FCT(get_node_or_nil);
API_FCT(get_wielded_item);
+ API_FCT(disconnect);
}
diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h
index b79cc670d..d7f92ac1c 100644
--- a/src/script/lua_api/l_client.h
+++ b/src/script/lua_api/l_client.h
@@ -41,6 +41,9 @@ private:
// send_respawn()
static int l_send_respawn(lua_State *L);
+ // disconnect()
+ static int l_disconnect(lua_State *L);
+
// gettext(text)
static int l_gettext(lua_State *L);