From e39bc37271d20fe81ce0a48807dfdb9caa5f72b7 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Thu, 28 Dec 2006 22:55:41 +0000 Subject: [PATCH] Warn if Auto3 scripts are loaded into Auto4-lua Originally committed to SVN as r649. --- core/auto4_lua.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/auto4_lua.cpp b/core/auto4_lua.cpp index b9e00f785..8fe84ce8f 100644 --- a/core/auto4_lua.cpp +++ b/core/auto4_lua.cpp @@ -180,6 +180,13 @@ namespace Automation4 { } } _stackcheck.check(0); + lua_getglobal(L, "version"); + if (lua_isnumber(L, -1)) { + if (lua_tointeger(L, -1) == 3) { + lua_pop(L, 1); // just to avoid tripping the stackcheck in debug + throw _T("This script looks like an Automation 3 Lua script. Automation 3 is not supported in this version of Aegisub, please use Aegisub 1.10 or earlier to use this script."); + } + } lua_getglobal(L, "script_name"); if (lua_isstring(L, -1)) { name = wxString(lua_tostring(L, -1), wxConvUTF8); @@ -198,7 +205,7 @@ namespace Automation4 { if (lua_isstring(L, -1)) { version = wxString(lua_tostring(L, -1), wxConvUTF8); } - lua_pop(L, 4); + lua_pop(L, 5); // if we got this far, the script should be ready _stackcheck.check(0);