Index: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt	(revision 1075)
+++ code/trunk/CMakeLists.txt	(revision 1076)
@@ -55,5 +55,5 @@
 # FIND_PACKAGE(CEGUI_OGRE)
 FIND_PACKAGE(ENet)
-FIND_PACKAGE(Boost REQUIRED thread)
+FIND_PACKAGE(Boost)
 FIND_PACKAGE(OpenAL)
 FIND_PACKAGE(ALUT)
@@ -70,6 +70,4 @@
   ${Boost_LIBRARY_DIRS}
   ${Zlib_LIBRARY_DIR}
-  ${Lua_LIBRARIES}
-#  core objects loader network weapon classHierarchy audio
 )
 
@@ -81,5 +79,5 @@
   ${ENet_INCLUDE_DIR}
   ${Boost_INCLUDE_DIRS}
-#  ${OPENAL_INCLUDE_DIR} ${ALUT_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIR}
+  ${OPENAL_INCLUDE_DIR} ${ALUT_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIR}
   ${Lua_INCLUDE_DIR}
 )
@@ -88,4 +86,14 @@
 ################ Source files ###################
 
+#At first, build lua
+MESSAGE(STATUS "\n******************* Building tolua... ******************\n\n")
+EXECUTE_PROCESS(COMMAND ./tolua-build)
+MESSAGE(STATUS "\n\n******************* Building tolua done ****************\n")
+
+#generate lua bind source files
+EXECUTE_PROCESS(COMMAND bin/./tolua-exec-script)
+EXECUTE_PROCESS(COMMAND ls)
+
 #add main source dir
 ADD_SUBDIRECTORY(src)
+
Index: code/trunk/bin/tolua-exec-script
===================================================================
--- code/trunk/bin/tolua-exec-script	(revision 1076)
+++ code/trunk/bin/tolua-exec-script	(revision 1076)
@@ -0,0 +1,3 @@
+cd src/core/tolua
+../../../bin/./tolua -n orxonox -o tolua_bind.cc -H tolua_bind.h tolua.pkg
+cd ../../../
Index: code/trunk/cmake/FindLua.cmake
===================================================================
--- code/trunk/cmake/FindLua.cmake	(revision 1075)
+++ code/trunk/cmake/FindLua.cmake	(revision 1076)
@@ -11,4 +11,5 @@
 # Redistribution and use is allowed according to the terms of the BSD license.
 
+MESSAGE(STATUS "lua libs in cache: ${Lua_LIBRARIES}")
 IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
     SET(Lua_FIND_QUIETLY TRUE) # Already in cache, be silent
@@ -26,5 +27,5 @@
 
 IF (NOT Lua_INCLUDE_DIR)
-FIND_PATH(Lua_INCLUDE_DIR lua.h
+ FIND_PATH(Lua_INCLUDE_DIR lua.h
 	/usr/include/lua50
 	/usr/local/include/lua50
@@ -33,25 +34,24 @@
 
 IF (NOT Lua_LIBRARIES)
-FIND_LIBRARY(Lua_LIBRARIES lua50
+ FIND_LIBRARY(Lua_LIBRARIES lua50
 	/usr/lib
 	/usr/local/lib)
 
-FIND_LIBRARY(Lua_LIBRARY lualib50
+ FIND_LIBRARY(Lua_LIBRARY lualib50
 	/usr/lib
 	/usr/local/lib)
 
-SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})
-
+#SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})
 ENDIF (NOT Lua_LIBRARIES)
 
+#especially for tardis
 IF (NOT Lua_LIBRARIES)
-FIND_LIBRARY(Lua_LIBRARIES lua
+ FIND_LIBRARY(Lua_LIBRARIES lua
 	/usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib)
 
-FIND_LIBRARY(Lua_LIBRARY lualib
+ FIND_LIBRARY(Lua_LIBRARY lualib
 	/usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib)
 
-SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})
-
+#SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})
 ENDIF (NOT Lua_LIBRARIES)
 
@@ -62,4 +62,5 @@
 IF (Lua_FOUND)
     MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}")
+    MESSAGE(STATUS "Found Lua: ${Lua_LIBRARY}")
 ELSE (Lua_FOUND)
     IF (Lua_FIND_REQUIRED)
Index: code/trunk/src/CMakeLists.txt
===================================================================
--- code/trunk/src/CMakeLists.txt	(revision 1075)
+++ code/trunk/src/CMakeLists.txt	(revision 1076)
@@ -1,4 +1,5 @@
 INCLUDE_DIRECTORIES(.)
 INCLUDE_DIRECTORIES(orxonox)
+INCLUDE_DIRECTORIES(util/tolua)
 
 ADD_SUBDIRECTORY(util)
Index: code/trunk/src/core/CMakeLists.txt
===================================================================
--- code/trunk/src/core/CMakeLists.txt	(revision 1075)
+++ code/trunk/src/core/CMakeLists.txt	(revision 1076)
@@ -1,2 +1,7 @@
+#get the created files
+AUX_SOURCE_DIRECTORY(tolua TOLUA_BIND_FILES) 
+
+MESSAGE(STATUS "tolua sources: ${TOLUA_BIND_FILES}")
+
 SET( CORE_SRC_FILES
   OrxonoxClass.cc
@@ -26,5 +31,5 @@
   Tickable.cc
   Script.cc
-  ToLuaBind.cc
+  ${TOLUA_BIND_FILES}
 )
 
@@ -34,4 +39,5 @@
   util
   ${Lua_LIBRARIES}
+  ${Lua_LIBRARY}
   ${OIS_LIBRARIES}
 )
Index: code/trunk/src/core/Script.cc
===================================================================
--- code/trunk/src/core/Script.cc	(revision 1075)
+++ code/trunk/src/core/Script.cc	(revision 1076)
@@ -39,6 +39,6 @@
 }
 
-#include "util/tolua/tolua++.h"
-#include "ToLuaBind.h"
+#include "tolua++.h"
+#include "tolua/tolua_bind.h"
 
 namespace orxonox
Index: code/trunk/src/core/Script_clean.h
===================================================================
--- code/trunk/src/core/Script_clean.h	(revision 1076)
+++ code/trunk/src/core/Script_clean.h	(revision 1076)
@@ -0,0 +1,83 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file  script.h
+ @brief Representation of an interface to lua
+ @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _Script_H__
+#define _Script_H__
+
+#include "CorePrereqs.h"
+
+extern "C" {
+#include <lua.h>
+}
+
+#include <list>
+#include <string>
+
+namespace orxonox // tolua_export
+{ // tolua_export
+
+  class  Script // tolua_export
+  { // tolua_export
+    public:
+      inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export
+      inline ~Script() { Script::singletonRef = NULL; };
+
+    void loadFile(std::string filename, bool luaTags);
+    //void init(lua_State *state_);
+    //void xmlToLua();
+    void run();
+    void luaPrint(std::string str); // tolua_export
+
+#if LUA_VERSION_NUM != 501
+    inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;};
+#endif
+
+    inline lua_State* getLuaState() { return luaState_; };
+    inline std::string getLuaOutput() { return output_; };
+    //inline std::string* getFileString() { return &fileString_; };
+
+    unsigned int getNextQuote(const std::string& text, unsigned int start);
+    std::string replaceLuaTags(const std::string& text);
+
+    private:
+      Script();
+      static Script* singletonRef;
+
+      std::string luaSource_;
+      std::string output_;
+      lua_State* luaState_;
+
+  }; // tolua_export
+} // tolua_export
+#endif /* _Script_H__ */
Index: code/trunk/src/core/ToLuaBind.cc
===================================================================
--- code/trunk/src/core/ToLuaBind.cc	(revision 1075)
+++ 	(revision )
@@ -1,110 +1,0 @@
-/*
-** Lua binding: orxonox
-** Generated automatically by tolua++-1.0.92 on Sun Apr  6 15:44:17 2008.
-*/
-
-#ifndef __cplusplus
-#include "stdlib.h"
-#endif
-#include "string.h"
-
-#include "util/tolua/tolua++.h"
-
-/* Exported function */
-TOLUA_API int  tolua_orxonox_open (lua_State* tolua_S);
-
-#include "Script.h"
-
-/* function to register type */
-static void tolua_reg_types (lua_State* tolua_S)
-{
- tolua_usertype(tolua_S,"orxonox::Script");
-}
-
-/* method: getInstance of class  orxonox::Script */
-#ifndef TOLUA_DISABLE_tolua_orxonox_orxonox_Script_getInstance00
-static int tolua_orxonox_orxonox_Script_getInstance00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
-     !tolua_isusertable(tolua_S,1,"orxonox::Script",0,&tolua_err) ||
-     !tolua_isnoobj(tolua_S,2,&tolua_err)
- )
-  goto tolua_lerror;
- else
-#endif
- {
-  {
-   orxonox::Script* tolua_ret = (orxonox::Script*)  orxonox::Script::getInstance();
-    tolua_pushusertype(tolua_S,(void*)tolua_ret,"orxonox::Script");
-  }
- }
- return 1;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'getInstance'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
-/* method: luaPrint of class  orxonox::Script */
-#ifndef TOLUA_DISABLE_tolua_orxonox_orxonox_Script_luaPrint00
-static int tolua_orxonox_orxonox_Script_luaPrint00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
-     !tolua_isusertype(tolua_S,1,"orxonox::Script",0,&tolua_err) ||
-     !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
-     !tolua_isnoobj(tolua_S,3,&tolua_err)
- )
-  goto tolua_lerror;
- else
-#endif
- {
-  orxonox::Script* self = (orxonox::Script*)  tolua_tousertype(tolua_S,1,0);
-  std::string str = ((std::string)  tolua_tocppstring(tolua_S,2,0));
-#ifndef TOLUA_RELEASE
-  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'luaPrint'",NULL);
-#endif
-  {
-   self->luaPrint(str);
-  }
- }
- return 0;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'luaPrint'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
-/* Open function */
-TOLUA_API int tolua_orxonox_open (lua_State* tolua_S)
-{
- tolua_open(tolua_S);
- tolua_reg_types(tolua_S);
- tolua_module(tolua_S,NULL,0);
- tolua_beginmodule(tolua_S,NULL);
-  tolua_module(tolua_S,"orxonox",0);
-  tolua_beginmodule(tolua_S,"orxonox");
-   tolua_cclass(tolua_S,"Script","orxonox::Script","",NULL);
-   tolua_beginmodule(tolua_S,"Script");
-    tolua_function(tolua_S,"getInstance",tolua_orxonox_orxonox_Script_getInstance00);
-    tolua_function(tolua_S,"luaPrint",tolua_orxonox_orxonox_Script_luaPrint00);
-   tolua_endmodule(tolua_S);
-  tolua_endmodule(tolua_S);
- tolua_endmodule(tolua_S);
- return 1;
-}
-
-
-#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
- TOLUA_API int luaopen_orxonox (lua_State* tolua_S) {
- return tolua_orxonox_open(tolua_S);
-};
-#endif
-
Index: code/trunk/src/core/ToLuaBind.h
===================================================================
--- code/trunk/src/core/ToLuaBind.h	(revision 1075)
+++ 	(revision )
@@ -1,10 +1,0 @@
-/*
-** Lua binding: orxonox
-** Generated automatically by tolua++-1.0.92 on Sun Apr  6 15:44:17 2008.
-*/
-
-#include "CorePrereqs.h"
-
-/* Exported function */
-TOLUA_API int  tolua_orxonox_open (lua_State* tolua_S);
-
Index: code/trunk/src/core/tolua.pkg
===================================================================
--- code/trunk/src/core/tolua.pkg	(revision 1075)
+++ 	(revision )
@@ -1,1 +1,0 @@
-$cfile "../../orxonox/core/Script.h"
Index: code/trunk/src/core/tolua/tolua.pkg
===================================================================
--- code/trunk/src/core/tolua/tolua.pkg	(revision 1076)
+++ code/trunk/src/core/tolua/tolua.pkg	(revision 1076)
@@ -0,0 +1,1 @@
+$cfile "../Script_clean.h"
Index: code/trunk/src/util/CMakeLists.txt
===================================================================
--- code/trunk/src/util/CMakeLists.txt	(revision 1075)
+++ code/trunk/src/util/CMakeLists.txt	(revision 1076)
@@ -1,3 +1,4 @@
 AUX_SOURCE_DIRECTORY(tinyxml TINYXML_SRC_FILES)
+AUX_SOURCE_DIRECTORY(tolua   TOLUA_SRC_FILES)
 
 SET (UTIL_SRC_FILES
@@ -11,4 +12,5 @@
   MultiTypeMath.cc
   ${TINYXML_SRC_FILES}
+  ${TOLUA_SRC_FILES}
 )
 
@@ -21,3 +23,6 @@
 TARGET_LINK_LIBRARIES( util
   ${OGRE_LIBRARIES}
-)
+  ${Lua_LIBRARIES}
+  ${Lua_LIBRARY}
+) 
+
Index: code/trunk/src/util/tolua/CMakeLists.txt
===================================================================
--- code/trunk/src/util/tolua/CMakeLists.txt	(revision 1075)
+++ code/trunk/src/util/tolua/CMakeLists.txt	(revision 1076)
@@ -2,5 +2,5 @@
 
 #This sets where to look for modules (e.g. "Find*.cmake" files)
-SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/)
 
 #Check whether we are on a tardis box
@@ -17,6 +17,6 @@
 
 #set binary output directories
-SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
-SET(LIBRARY_OUTPUT_PATH    ${PROJECT_BINARY_DIR}/bin/lib)
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../../../bin)
+SET(LIBRARY_OUTPUT_PATH    ${PROJECT_BINARY_DIR}/../../../bin)
 
 # global compiler/linker flags. force -O2!
@@ -39,6 +39,4 @@
 #Set the search paths for the linking
 LINK_DIRECTORIES(
-  ${Lua_LIBRARIES}
-  m
 )
 
@@ -65,3 +63,5 @@
 TARGET_LINK_LIBRARIES( tolua
   ${Lua_LIBRARIES}
+  ${Lua_LIBRARY}
+  m
 )
Index: code/trunk/tolua-build
===================================================================
--- code/trunk/tolua-build	(revision 1076)
+++ code/trunk/tolua-build	(revision 1076)
@@ -0,0 +1,4 @@
+cd src/util/tolua/
+cmake .
+make
+cd ../../../
