CLuaInstance: Script function 'checkVersion' terminated an error...

...occurs immediately the script

Complement to commit 00dff2c598

- Set Lua api version to 1.4
This commit is contained in:
M. Liebmann
2015-09-17 14:48:11 +02:00
parent c6dedf148f
commit 1e76cac3ba
2 changed files with 4 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -34,7 +34,7 @@ extern "C" {
#include <vector>
#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