diff -ru --exclude '*.in' --exclude '*.~' --exclude '*.cache' --exclude configure CEGUI-0.5.0/aclocal.m4 CEGUI_work/aclocal.m4 --- CEGUI-0.5.0/aclocal.m4 2006-11-28 11:17:05.000000000 +0100 +++ CEGUI_work/aclocal.m4 2007-05-08 16:53:03.000000000 +0200 @@ -551,6 +551,17 @@ AC_DEFUN([CEGUI_CHECK_LUA],[ PKG_CHECK_MODULES(Lua, lua >= 5.0 lua < 5.1, [cegui_found_lua=yes], [cegui_found_lua=no]) + + LUA_VERSION_FLAGS=""; + if test x$cegui_found_lua = xno; then + PKG_CHECK_MODULES(Lua, lua >= 5.1, [cegui_found_lua=yes], [cegui_found_lua=no]) + + if test x$cegui_found_lua = xyes; then + LUA_VERSION_FLAGS="$LUA_VERSION_FLAGS -DLUA51" + AC_MSG_NOTICE([Lua version >=5.1]) + fi + fi + AC_SUBST(LUA_VERSION_FLAGS) AC_ARG_ENABLE([lua-module], AC_HELP_STRING([--disable-lua-module], [Disables building of the Lua scripting module.]), [cegui_with_lua=$enableval], [cegui_with_lua=yes]) diff -ru --exclude '*.in' --exclude '*.~' --exclude '*.cache' --exclude configure CEGUI-0.5.0/ScriptingModules/CEGUILua/LuaScriptModule/src/CEGUILua.cpp CEGUI_work/ScriptingModules/CEGUILua/LuaScriptModule/src/CEGUILua.cpp --- CEGUI-0.5.0/ScriptingModules/CEGUILua/LuaScriptModule/src/CEGUILua.cpp 2006-06-19 22:20:17.000000000 +0200 +++ CEGUI_work/ScriptingModules/CEGUILua/LuaScriptModule/src/CEGUILua.cpp 2007-05-08 18:41:56.000000000 +0200 @@ -35,12 +35,10 @@ // include Lua libs and tolua++ extern "C" { -#include "lua.h" +#include "tolua++.h" #include "lualib.h" -#include "lauxlib.h" } -#include "tolua++.h" // prototype for bindings initialisation function int tolua_CEGUI_open(lua_State* tolua_S); @@ -55,11 +53,36 @@ *************************************************************************/ LuaScriptModule::LuaScriptModule() { +#ifdef LUA51 + static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, +#if defined(DEBUG) || defined (_DEBUG) + {LUA_DBLIBNAME, luaopen_debug}, +#endif + {NULL, NULL} + }; +#endif /* LUA51 */ + // create a lua state d_ownsState = true; d_state = lua_open(); // init all standard libraries +#ifdef LUA51 + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) + { + lua_pushcfunction(d_state, lib->func); + lua_pushstring(d_state, lib->name); + lua_call(d_state, 1, 0); + } +#else /* LUA51 */ luaopen_base(d_state); luaopen_io(d_state); luaopen_string(d_state); @@ -68,7 +91,7 @@ #if defined(DEBUG) || defined (_DEBUG) luaopen_debug(d_state); #endif - +#endif /* LUA51 */ setModuleIdentifierString(); } diff -ru --exclude '*.in' --exclude '*.~' --exclude '*.cache' --exclude configure CEGUI-0.5.0/ScriptingModules/CEGUILua/LuaScriptModule/src/Makefile.am CEGUI_work/ScriptingModules/CEGUILua/LuaScriptModule/src/Makefile.am --- CEGUI-0.5.0/ScriptingModules/CEGUILua/LuaScriptModule/src/Makefile.am 2006-07-25 10:34:51.000000000 +0200 +++ CEGUI_work/ScriptingModules/CEGUILua/LuaScriptModule/src/Makefile.am 2007-05-08 16:56:04.000000000 +0200 @@ -1,6 +1,7 @@ INCLUDES = -I$(top_srcdir)/include \ -I$(top_srcdir)/ScriptingModules/CEGUILua/tolua++ \ - -I$(top_srcdir)/ScriptingModules/CEGUILua/LuaScriptModule/include + -I$(top_srcdir)/ScriptingModules/CEGUILua/LuaScriptModule/include \ + ${LUA_VERSION_FLAGS} lib_LTLIBRARIES = libCEGUILuaScriptModule.la libCEGUILuaScriptModule_la_LDFLAGS = -version-info @CEGUI_VERSION_INFO@