Index: /branches/script_engine/src/lib/script_engine/LuaCallback.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/LuaCallback.cc	(revision 7654)
+++ /branches/script_engine/src/lib/script_engine/LuaCallback.cc	(revision 7654)
@@ -0,0 +1,116 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Silvan Nellen
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
+
+#include "Script.h"
+#include "LuaCallback.h"
+#include "luaincl.h"
+#include "scriptable.h"
+
+#include <cassert>
+#include <string>
+#include <iostream>
+#include <stdio.h>
+
+namespace OrxScript
+{
+
+  /**
+   * @brief This function accually executes a method called by Lua.
+   * @param lua Since this function gets called by lua it has to have a lua_State as parameter
+   * @return the number of return values. (which can be found on the stack)
+   *
+   * For Lua doesn't know how to handle C++ objects it pushes the Objecttable (including the objectpointer) on top of the stack and
+   * calls this function.
+   *
+   * @todo handle an acces to a nonexistent (deleted) object
+   */
+  int luaCallback (lua_State *lua)
+  {
+
+    // Locate the psudo-index for the function number
+    int methodNumber = lua_upvalueindex (1);
+    int returnCount = 0;
+
+    bool functionSuccess = false;
+
+    // Check for the "this" table
+    if (lua_istable (lua, 1))
+    {
+      // Found the "this" table. The object pointer is at the index 0
+      lua_rawgeti (lua, 1, 0);
+
+      if (lua_islightuserdata (lua, -1))
+      {
+        // Found the pointer, need to cast it
+        Scriptable* thisPointer = (Scriptable*) lua_touserdata (lua, -1);
+
+        // Get the method index
+        int methodIndex = (int) lua_tonumber (lua, methodNumber);
+
+        // Reformat the stack so our parameters are correct
+        // Clean up the "this" table
+        lua_remove (lua, 1);
+        // Clean up the thisPointer pointer
+        lua_remove (lua, -1);
+
+        //debug
+        //std::cout<<thisPointer->whatIsThis()<<std::endl;
+
+        LuaScript* originScript = NULL;
+
+        lua_getglobal (lua, "this");
+
+        if (lua_istable (lua, 1))
+        {
+          // Found the "this" table. The object pointer is at the index 0
+          lua_rawgeti (lua, 1, 0);
+
+          if (lua_islightuserdata (lua, -1))
+          {
+            // Found the pointer, need to cast it
+            originScript = (LuaScript *) lua_touserdata (lua, -1);
+          }
+        }
+
+        if(originScript == NULL)
+        {//do something usefull
+        }
+        //debug
+        // std::cout<<originScript->whatIsThis()<<std::endl;
+
+        LuaVirtualMachine virtualMachine = originScript->getVirtualMachine();
+        //debug
+        //std::cout<<"test "<< thisPointer->methods(virtualMachine)<<std::endl;
+        // Check that the method is correct index
+        assert ((methodIndex <= thisPointer->methods(virtualMachine) ));
+        // Call the class
+        returnCount = thisPointer->scriptCalling ( virtualMachine, thisPointer->getFunctionAtIndex(methodIndex,virtualMachine));
+
+        functionSuccess = true;
+      }
+    }
+
+    if (functionSuccess == false)
+    {
+      lua_pushstring (lua, "luaCallback -> Failed to call the class function");
+      lua_error (lua);
+    }
+
+    // Number of return variables
+    return returnCount;
+  }
+}
Index: /branches/script_engine/src/lib/script_engine/LuaCallback.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/LuaCallback.h	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/LuaCallback.h	(revision 7654)
@@ -2,104 +2,10 @@
 #define __LUA_CALLBACK_H__
 
-#include <assert.h>
-#include <string>
-#include <iostream>
-#include <stdio.h>
+struct lua_State;
 
 namespace OrxScript
 {
   class LuaVirtualMachine;
-
-
-  /**
-   * @brief This function accually executes a method called by Lua.
-   *
-   * @param lua Since this function gets called by lua it has to have a lua_State as parameter
-   *
-   * @return the number of return values. (which can be found on the stack)
-   *
-   * For Lua doesn't know how to handle C++ objects it pushes the Objecttable (including the objectpointer) on top of the stack and
-   * calls this function.
-   *
-   *
-   * @todo handle an acces to a nonexistent (deleted) object
-   */
-
-
-  static int luaCallback (lua_State *lua)
-  {
-
-    // Locate the psudo-index for the function number
-    int methodNumber = lua_upvalueindex (1);
-    int returnCount = 0;
-
-    bool functionSuccess = false;
-
-    // Check for the "this" table
-    if (lua_istable (lua, 1))
-    {
-      // Found the "this" table. The object pointer is at the index 0
-      lua_rawgeti (lua, 1, 0);
-
-      if (lua_islightuserdata (lua, -1))
-      {
-        // Found the pointer, need to cast it
-        Scriptable* thisPointer = (Scriptable*) lua_touserdata (lua, -1);
-
-        // Get the method index
-        int methodIndex = (int) lua_tonumber (lua, methodNumber);
-
-        // Reformat the stack so our parameters are correct
-        // Clean up the "this" table
-        lua_remove (lua, 1);
-        // Clean up the thisPointer pointer
-        lua_remove (lua, -1);
-
-        //debug
-        //std::cout<<thisPointer->whatIsThis()<<std::endl;
-
-        LuaScript* originScript = NULL;
-
-        lua_getglobal (lua, "this");
-
-        if (lua_istable (lua, 1))
-        {
-          // Found the "this" table. The object pointer is at the index 0
-          lua_rawgeti (lua, 1, 0);
-
-          if (lua_islightuserdata (lua, -1))
-          {
-            // Found the pointer, need to cast it
-            originScript = (LuaScript *) lua_touserdata (lua, -1);
-          }
-        }
-
-        if(originScript == NULL)
-        {//do something usefull
-        }
-        //debug
-        // std::cout<<originScript->whatIsThis()<<std::endl;
-
-        LuaVirtualMachine virtualMachine = originScript->getVirtualMachine();
-        //debug
-        //std::cout<<"test "<< thisPointer->methods(virtualMachine)<<std::endl;
-        // Check that the method is correct index
-        assert ((methodIndex <= thisPointer->methods(virtualMachine) ));
-        // Call the class
-        returnCount = thisPointer->scriptCalling ( virtualMachine, thisPointer->getFunctionAtIndex(methodIndex,virtualMachine));
-
-        functionSuccess = true;
-      }
-    }
-
-    if (functionSuccess == false)
-    {
-      lua_pushstring (lua, "luaCallback -> Failed to call the class function");
-      lua_error (lua);
-    }
-
-    // Number of return variables
-    return returnCount;
-  }
+  int luaCallback (lua_State *lua);
 }
 #endif /* __LUA_CALLBACK_H__*/
Index: /branches/script_engine/src/lib/script_engine/Makefile.am
===================================================================
--- /branches/script_engine/src/lib/script_engine/Makefile.am	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/Makefile.am	(revision 7654)
@@ -5,6 +5,9 @@
 
 libORXscript_a_SOURCES = \
+		LuaCallback.cc \
+		RestoreStack.cc \
 		Script.cc \
 		scriptable.cc\
+		This.cc \
 		VirtualMachine.cc
 
Index: /branches/script_engine/src/lib/script_engine/RestoreStack.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/RestoreStack.cc	(revision 7654)
+++ /branches/script_engine/src/lib/script_engine/RestoreStack.cc	(revision 7654)
@@ -0,0 +1,46 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: ...
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
+
+#include "RestoreStack.h"
+#include "luaincl.h"
+
+namespace OrxScript
+{
+
+  /**
+   * @brief Stores the stack and the index to the top element
+   *
+   * @param virtualMachine the virtual machine to save
+   */
+  LuaRestoreStack::LuaRestoreStack (LuaVirtualMachine& virtualMachine) : savedState (NULL)
+  {
+    savedState = (lua_State *) virtualMachine;
+    if (virtualMachine.isOk ())
+    {
+      savedTopIndex = lua_gettop (savedState);
+    }
+  }
+  /**
+  * @brief Restores the virtual machine
+  *
+  *
+  */
+  LuaRestoreStack::~LuaRestoreStack ()
+  {
+    lua_settop (savedState, savedTopIndex);
+  }
+}
Index: /branches/script_engine/src/lib/script_engine/RestoreStack.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/RestoreStack.h	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/RestoreStack.h	(revision 7654)
@@ -2,5 +2,8 @@
 #define __RESTORE_STACK_H__
 
-#include "luaincl.h"
+
+#include "VirtualMachine.h"
+/// Forward declaration
+struct lua_State;
 
 namespace OrxScript
@@ -16,21 +19,6 @@
      * @param virtualMachine the virtual machine to save
      */
-    LuaRestoreStack (LuaVirtualMachine& virtualMachine) : savedState (NULL)
-    {
-      savedState = (lua_State *) virtualMachine;
-      if (virtualMachine.isOk ())
-      {
-        savedTopIndex = lua_gettop (savedState);
-      }
-    }
-    /**
-     * @brief Restores the virtual machine
-     *
-     *
-     */
-    virtual ~LuaRestoreStack (void)
-    {
-      lua_settop (savedState, savedTopIndex);
-    }
+    LuaRestoreStack (LuaVirtualMachine& virtualMachine);
+    virtual ~LuaRestoreStack (void);
 
   protected:
Index: /branches/script_engine/src/lib/script_engine/Script.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/Script.cc	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/Script.cc	(revision 7654)
@@ -1,4 +1,5 @@
-#include <assert.h>
+#include <cassert>
 #include <string>
+#include <iostream>
 
 #include "Script.h"
@@ -224,13 +225,12 @@
    */
 
-  void LuaScript::addParam (char *string)
-  {
-    assert (string != NULL && "LuaScript::addParam -> string == NULL");
-    assert (virtualMachine.isOk () && "VM Not OK");
-
-    BEGIN_LUA_CHECK (virtualMachine)
-    lua_pushstring (state, string);
+  void LuaScript::addParam (const std::string& string)
+  {
+    assert (virtualMachine.isOk () && "VM Not OK");
+
+    BEGIN_LUA_CHECK (virtualMachine);
+    lua_pushstring (state, string.c_str());
     ++argumentCount;
-    END_LUA_CHECK
+    END_LUA_CHECK;
   }
 
Index: /branches/script_engine/src/lib/script_engine/Script.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/Script.h	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/Script.h	(revision 7654)
@@ -5,5 +5,4 @@
 
 #include "VirtualMachine.h"
-#include "luaincl.h"
 #include "scriptable.h"
 
@@ -40,5 +39,5 @@
     void addParam (int iInt);
     void addParam (float fFloat);
-    void addParam (char *string);
+    void addParam (const std::string& string);
 
     // Runs the loaded script
@@ -62,5 +61,5 @@
     /* ------------------- Handle external Objects ------------------ */
 
-    void removeFromScript(int referenceToScriptable){}
+    void removeFromScript(int referenceToScriptable) {}
     int addScriptableToScript(Scriptable* scriptbl,const std::string& name);  // name= name the scriptable goes by in lua
     int addFunctionToScriptable(const std::string& strFuncName, int toScriptable, int lastMethodIndex);
Index: /branches/script_engine/src/lib/script_engine/This.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/This.cc	(revision 7654)
+++ /branches/script_engine/src/lib/script_engine/This.cc	(revision 7654)
@@ -0,0 +1,49 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Silvan Nellen
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
+
+#include "This.h"
+#include "luaincl.h"
+
+namespace OrxScript
+{
+  LuaThis::LuaThis (LuaVirtualMachine& vm, int iRef) : oldReference (0), virtualMachine (vm)
+  {
+    lua_State *state = (lua_State *) vm;
+    if (vm.isOk ())
+    {
+      // Save the old "this" table
+      lua_getglobal (state, "this");
+      oldReference = luaL_ref (state, LUA_REGISTRYINDEX);
+
+      // replace it with our new one
+      lua_rawgeti(state, LUA_REGISTRYINDEX, iRef);
+      lua_setglobal (state, "this");
+    }
+  }
+
+  LuaThis::~LuaThis (void)
+  {
+    lua_State *state = (lua_State *) virtualMachine;
+    if (oldReference > 0 && virtualMachine.isOk ())
+    {
+      // Replace the old "this" table
+      lua_rawgeti(state, LUA_REGISTRYINDEX, oldReference);
+      lua_setglobal (state, "this");
+      luaL_unref (state, LUA_REGISTRYINDEX, oldReference);
+    }
+  }
+}
Index: /branches/script_engine/src/lib/script_engine/This.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/This.h	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/This.h	(revision 7654)
@@ -3,5 +3,4 @@
 
 #include "VirtualMachine.h"
-#include "luaincl.h"
 
 // Sets the "this" global table that scripts use
@@ -12,31 +11,6 @@
   {
   public:
-    LuaThis (LuaVirtualMachine& vm, int iRef) : oldReference (0), virtualMachine (vm)
-    {
-      lua_State *state = (lua_State *) vm;
-      if (vm.isOk ())
-      {
-        // Save the old "this" table
-        lua_getglobal (state, "this");
-        oldReference = luaL_ref (state, LUA_REGISTRYINDEX);
-
-        // replace it with our new one
-        lua_rawgeti(state, LUA_REGISTRYINDEX, iRef);
-        lua_setglobal (state, "this");
-      }
-    }
-
-    virtual ~LuaThis (void)
-    {
-      lua_State *state = (lua_State *) virtualMachine;
-      if (oldReference > 0 && virtualMachine.isOk ())
-      {
-        // Replace the old "this" table
-        lua_rawgeti(state, LUA_REGISTRYINDEX, oldReference);
-        lua_setglobal (state, "this");
-        luaL_unref (state, LUA_REGISTRYINDEX, oldReference);
-      }
-    }
-
+    LuaThis (LuaVirtualMachine& vm, int iRef);
+    virtual ~LuaThis (void);
 
   protected:
Index: /branches/script_engine/src/lib/script_engine/VirtualMachine.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/VirtualMachine.h	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/VirtualMachine.h	(revision 7654)
@@ -24,6 +24,6 @@
 
     // Get the state of the lua stack (use the cast operator)
-    //lua_State *GetState (void) { return luaState; }
-    operator lua_State *(void) { return luaState; }
+    lua_State* getState (void) const{ return luaState; }
+    operator lua_State* (void) const { return luaState; }
 
     static void panic (lua_State *lua);
Index: /branches/script_engine/src/lib/script_engine/scriptable.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/scriptable.cc	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/scriptable.cc	(revision 7654)
@@ -1,4 +1,6 @@
-#include <assert.h>
+#include <cassert>
 #include <string>
+#include <iostream>
+
 #include <map>
 #include <list>
Index: /branches/script_engine/src/lib/script_engine/scriptable.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/scriptable.h	(revision 7653)
+++ /branches/script_engine/src/lib/script_engine/scriptable.h	(revision 7654)
@@ -26,4 +26,6 @@
   class Scriptable
   {
+    friend class LuaScript;
+
   public:
     Scriptable (void);
@@ -62,5 +64,4 @@
 
 
-    friend class LuaScript;
 
     std::list<std::string> functionList;
