From 1e76cac3bad4083af7fc3acd62eef27a5b9d786b Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Thu, 17 Sep 2015 14:48:11 +0200 Subject: [PATCH] CLuaInstance: Script function 'checkVersion' terminated an error... ...occurs immediately the script Complement to commit 00dff2c5985261b19cc54b2850f776b136b0f6af - Set Lua api version to 1.4 --- src/gui/luainstance.cpp | 7 +++---- src/gui/luainstance.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 149c9d503..7a94dd559 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -2691,20 +2691,19 @@ int CLuaInstance::checkVersion(lua_State *L) lua_pushnil(L); return 1; } - int major=0, minor=0, ret=1; + int major=0, minor=0; major = luaL_checkint(L, 2); minor = luaL_checkint(L, 3); if ((major > LUA_API_VERSION_MAJOR) || ((major == LUA_API_VERSION_MAJOR) && (minor > LUA_API_VERSION_MINOR))) { - ret = 0; char msg[1024]; snprintf(msg, sizeof(msg)-1, "%s (v%d.%d)\n%s v%d.%d", g_Locale->getText(LOCALE_LUA_VERSIONSCHECK1), LUA_API_VERSION_MAJOR, LUA_API_VERSION_MINOR, g_Locale->getText(LOCALE_LUA_VERSIONSCHECK2), major, minor); - DisplayErrorMessage(msg, "Lua Script Error:"); + luaL_error(L, msg); } - lua_pushinteger(L, ret); + lua_pushinteger(L, 1); /* for backward compatibility */ return 1; } diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 1dc3d4f1f..848f59588 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -34,7 +34,7 @@ extern "C" { #include #define LUA_API_VERSION_MAJOR 1 -#define LUA_API_VERSION_MINOR 2 +#define LUA_API_VERSION_MINOR 4 /* this is stored as userdata in the lua_State */ struct CLuaData