Index: configure.in
===================================================================
--- configure.in	(revision 7510)
+++ configure.in	(working copy)
@@ -178,6 +178,11 @@
 AC_CHECK_LIB(png,png_create_read_struct,,AC_MSG_ERROR([*** libpng not found!]))
 AC_SUBST(LIBPNG,-lpng)
 
+LUA_INCLUDES=-I/usr/local/include/lua51
+AC_SUBST(LUA_INCLUDES)
+LUA_LIBS="-L/usr/local/lib/lua51 -llua"
+AC_SUBST(LUA_LIBS)
+
 AC_C_CONST
 AC_C_INLINE
 AC_C_RESTRICT
@@ -199,7 +204,7 @@
 
 CPPFLAGS="$CPPFLAGS -DSYSCONFDIR=\\\"\$(sysconfdir)\\\" -DDATADIR=\\\"\$(moddir)\\\" -DPLUGINDIR=\\\"\$(plugindir)\\\""
 #CXXFLAGS="$CXXFLAGS -Werror -Wall -W -Wpointer-arith -Wcast-qual -Wwrite-strings -Wshadow -Wcast-align -ansi -pedantic -Wbad-function-cast -Winline -Wnested-externs -Wno-format-y2k -Wno-long-long"
-CXXFLAGS="$CXXFLAGS -Werror -Wall -W -Wpointer-arith -Wcast-align -ansi -pedantic -Wno-format-y2k -Wno-long-long -fno-strict-aliasing"
+CXXFLAGS="$CXXFLAGS -Wall -W -Wpointer-arith -Wcast-align -ansi -pedantic -Wno-format-y2k -Wno-long-long -fno-strict-aliasing"
 
 # only export symbols explicitly marked to be exported
 CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
@@ -250,6 +255,7 @@
 gemrb/plugins/PSTOpcodes/Makefile 
 gemrb/plugins/GAMImporter/Makefile 
 gemrb/plugins/GUIScript/Makefile 
+gemrb/plugins/LUAScript/Makefile 
 gemrb/plugins/IDSImporter/Makefile 
 gemrb/plugins/INIImporter/Makefile 
 gemrb/plugins/ITMImporter/Makefile 
Index: gemrb/plugins/GUIScript/GUIScript.cpp
===================================================================
--- gemrb/plugins/GUIScript/GUIScript.cpp	(revision 7510)
+++ gemrb/plugins/GUIScript/GUIScript.cpp	(working copy)
@@ -9328,6 +9328,23 @@
 	return PyString_FromString(splname);
 }
 
+PyDoc_STRVAR( GemRB_Lua__doc,
+"Lua(strref, color[,actor])\n\n"
+"The optional actor is the party ID of the character whose name will be displayed.\n\n");
+
+static PyObject* GemRB_Lua(PyObject * /*self*/, PyObject* args)
+{
+	char *luastr;
+
+	if (!PyArg_ParseTuple( args, "s", &luastr)) {
+		return AttributeError( GemRB_Lua__doc );
+	}
+	core->GetLUAScriptEngine()->ExecString( luastr );
+
+	Py_INCREF( Py_None );
+	return Py_None;
+}
+
 static PyMethodDef GemRBMethods[] = {
 	METHOD(ActOnPC, METH_VARARGS),
 	METHOD(AdjustScrolling, METH_VARARGS),
@@ -9583,6 +9600,7 @@
 	METHOD(UpdateAmbientsVolume, METH_NOARGS),
 	METHOD(UpdateMusicVolume, METH_NOARGS),
 	METHOD(UseItem, METH_VARARGS),
+	METHOD(Lua, METH_VARARGS),
 	// terminating entry
 	{NULL, NULL, 0, NULL}
 };
Index: gemrb/plugins/Core/Interface.h
===================================================================
--- gemrb/plugins/Core/Interface.h	(revision 7510)
+++ gemrb/plugins/Core/Interface.h	(working copy)
@@ -249,6 +249,7 @@
 	Window* ModalWindow;
 	char WindowPack[10];
 	ScriptEngine * guiscript;
+	ScriptEngine * luascript;
 	SaveGameIterator *sgiterator;
 	/** Windows Array */
 	std::vector<Window*> windows;
@@ -365,6 +366,8 @@
 	WindowMgr * GetWindowMgr() const;
 	/** Get GUI Script Manager */
 	ScriptEngine * GetGUIScriptEngine() const;
+	/** Get LUA Script Manager */
+	ScriptEngine * GetLUAScriptEngine() const;
 	/** core for summoning creatures, returns the last created Actor
 	may apply a single fx on the summoned creature normally an unsummon effect */
 	Actor *SummonCreature(const ieResRef resource, const ieResRef vvcres, Scriptable *Owner, Actor *target, Point &position, int eamod, int level, Effect *fx);
@@ -694,6 +697,7 @@
 	char PluginsPath[_MAX_PATH];
 	char CachePath[_MAX_PATH];
 	char GUIScriptsPath[_MAX_PATH];
+	char LUAScriptsPath[_MAX_PATH];
 	char GamePath[_MAX_PATH];
 	char SavePath[_MAX_PATH];
 	char INIConfig[_MAX_PATH];
Index: gemrb/plugins/Core/Interface.cpp
===================================================================
--- gemrb/plugins/Core/Interface.cpp	(revision 7510)
+++ gemrb/plugins/Core/Interface.cpp	(working copy)
@@ -189,6 +189,7 @@
 	KeepCache = false;
 	TooltipDelay = 100;
 	GUIScriptsPath[0] = 0;
+	LUAScriptsPath[0] = 0;
 	GamePath[0] = 0;
 	SavePath[0] = 0;
 	GemRBPath[0] = 0;
@@ -1412,6 +1413,20 @@
 	printStatus( "OK", LIGHT_GREEN );
 	strcpy( NextScript, "Start" );
 
+	printStatus( "OK", LIGHT_GREEN );
+	printMessage( "Core", "Initializing LUA Script Engine...", WHITE );
+	luascript = ( ScriptEngine * ) GetInterface( IE_LUA_SCRIPT_CLASS_ID );
+	if (luascript == NULL) {
+		printStatus( "ERROR", LIGHT_RED );
+		return GEM_ERROR;
+	}
+	if (!luascript->Init()) {
+		printStatus( "ERROR", LIGHT_RED );
+		return GEM_ERROR;
+	}
+	printStatus( "OK", LIGHT_GREEN );
+	//strcpy( NextScript, "Start" );
+
 	int ret = LoadSprites();
 	if (ret) return ret;
 
@@ -2061,6 +2076,9 @@
 		} else if (stricmp( name, "GUIScriptsPath" ) == 0) {
 			strncpy( GUIScriptsPath, value, sizeof(GUIScriptsPath) );
 			ResolveFilePath( GUIScriptsPath );
+		} else if (stricmp( name, "LUAScriptsPath" ) == 0) {
+			strncpy( LUAScriptsPath, value, sizeof(LUAScriptsPath) );
+			ResolveFilePath( LUAScriptsPath );
 		} else if (stricmp( name, "PluginsPath" ) == 0) {
 			strncpy( PluginsPath, value, sizeof(PluginsPath) );
 			ResolveFilePath( PluginsPath );
@@ -2105,6 +2123,10 @@
 		strcpy( GUIScriptsPath, GemRBPath );
 	}
 
+	if (!LUAScriptsPath[0]) {
+		strcpy( LUAScriptsPath, GemRBPath );
+	}
+
 	if (!GameName[0]) {
 		strcpy( GameName, GEMRB_STRING );
 	}
@@ -2120,6 +2142,7 @@
 
 
 	FixPath( GUIScriptsPath, true );
+	FixPath( LUAScriptsPath, true );
 	FixPath( PluginsPath, true );
 	FixPath( GemRBPath, true );
 	FixPath( GemRBOverridePath, true );
@@ -2413,6 +2436,12 @@
 	return guiscript;
 }
 
+/** Get LUA Script Manager */
+ScriptEngine* Interface::GetLUAScriptEngine() const
+{
+	return luascript;
+}
+
 //NOTE: if there were more summoned creatures, it will return only the last
 Actor *Interface::SummonCreature(const ieResRef resource, const ieResRef vvcres, Scriptable *Owner, Actor *target, Point &position, int eamod, int level, Effect *fx)
 {
Index: gemrb/plugins/Makefile.am
===================================================================
--- gemrb/plugins/Makefile.am	(revision 7510)
+++ gemrb/plugins/Makefile.am	(working copy)
@@ -1,6 +1,7 @@
 SUBDIRS = \
 	Core \
 	GUIScript \
+	LUAScript \
 	SDLVideo \
 	OpenALAudio \
 	ZLibMgr \
Index: gemrb/includes/SClassID.h
===================================================================
--- gemrb/includes/SClassID.h	(revision 7510)
+++ gemrb/includes/SClassID.h	(working copy)
@@ -77,6 +77,7 @@
 #define IE_SCRIPT_CLASS_ID		0x000D0000
 #define IE_GUI_SCRIPT_CLASS_ID		0x000E0000
 #define IE_COMPRESSION_CLASS_ID 	0x000F0000
+#define IE_LUA_SCRIPT_CLASS_ID		0x00200000
 
 enum {
 	PLUGIN_OPCODES_CORE =		0xABCD0001,
Index: TODO
===================================================================
--- TODO	(revision 7510)
+++ TODO	(working copy)
@@ -68,6 +68,8 @@
 3. valgrind reports a big heap of unreleased python objects
 4. Implement at least all the options accessible from the GUI options setup,
    rewrite baldur|torment|icewind.ini
+5. refactor Interface.cpp to several classes (interface, win manager, ...)
+6. simplify the plugin interface
 
 Graphics:
 1. use scaling in Video::SpriteScaleDown() instead of in Video::GetPreview() 
Index: autogen.sh
===================================================================
--- autogen.sh	(revision 7510)
+++ autogen.sh	(working copy)
@@ -7,7 +7,11 @@
 export WANT_AUTOCONF="2.5"
 
 # FreeBSD favourite paths
-#export CXXFLAGS="-ggdb -I/usr/local/include"
+#export CPPFLAGS="-I/usr/local/include -I/usr/include/g++"
+#export CXXCPPFLAGS="-I/usr/local/include -I/usr/include/g++"
+export CXXFLAGS="-ggdb -I/usr/local/include"
+export LDFLAGS="-ggdb -L/usr/local/lib"
+#export CXXFLAGS="-ggdb"
 #export LDFLAGS="-ggdb -L/usr/local/lib"
 
 if [ "$1" = "" ]; then
