Index: /code/branches/resource/src/core/LuaBind.cc
===================================================================
--- /code/branches/resource/src/core/LuaBind.cc	(revision 3339)
+++ /code/branches/resource/src/core/LuaBind.cc	(revision 3340)
@@ -39,5 +39,4 @@
 #include "util/Debug.h"
 #include "util/StringUtils.h"
-#include "ToluaBindCore.h"
 #include "Core.h"
 
@@ -65,8 +64,19 @@
     luaopen_debug(luaState_);
 #endif
-    tolua_Core_open(luaState_);
+
+    // Open all available tolua interfaces
+    this->openToluaInterfaces(luaState_);
+
     output_ = "";
     isRunning_ = false;
   }
+
+  LuaBind::~LuaBind()
+  {
+    this->closeToluaInterfaces(luaState_);
+
+    assert(singletonRef_s);
+    LuaBind::singletonRef_s = NULL;
+  };
 
   void LuaBind::luaPrint(const std::string& str)
@@ -315,3 +325,25 @@
   }
 
+  void LuaBind::addToluaInterface(int (*function)(lua_State*), const std::string& name)
+  {
+    toluaInterfaces_.push_back(std::make_pair(name, function));
+    // Apply changes to our own lua state as well 
+    (*function)(luaState_);
+  }
+
+  void LuaBind::openToluaInterfaces(lua_State* state)
+  {
+    for (unsigned int i = 0; i < toluaInterfaces_.size(); ++i)
+      (*toluaInterfaces_[i].second)(state);
+  }
+
+  void LuaBind::closeToluaInterfaces(lua_State* state)
+  {
+    for (unsigned int i = 0; i < toluaInterfaces_.size(); ++i)
+    {
+      lua_pushnil(state);
+      lua_setglobal(state, toluaInterfaces_[i].first.c_str());
+    }
+  }
+
 }
Index: /code/branches/resource/src/core/LuaBind.h
===================================================================
--- /code/branches/resource/src/core/LuaBind.h	(revision 3339)
+++ /code/branches/resource/src/core/LuaBind.h	(revision 3340)
@@ -58,5 +58,5 @@
     public:
       LuaBind();
-      inline ~LuaBind() { assert(singletonRef_s); LuaBind::singletonRef_s = NULL; };
+      ~LuaBind();
 
       inline static LuaBind& getInstance() { assert(singletonRef_s); return *LuaBind::singletonRef_s; } // tolua_export
@@ -83,4 +83,8 @@
         { this->includePath_ = includepath; }
 
+    void addToluaInterface(int (*function)(lua_State*), const std::string& name);
+    void openToluaInterfaces(lua_State* state);
+    void closeToluaInterfaces(lua_State* state);
+
     private:
       static LuaBind* singletonRef_s;
@@ -91,4 +95,5 @@
       bool isRunning_;
       std::string includePath_;
+      std::vector<std::pair<std::string, int (*)(lua_State *L)> > toluaInterfaces_;
 
   }; // tolua_export
Index: /code/branches/resource/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- /code/branches/resource/src/orxonox/gamestates/GSRoot.cc	(revision 3339)
+++ /code/branches/resource/src/orxonox/gamestates/GSRoot.cc	(revision 3340)
@@ -34,5 +34,8 @@
 #include "core/Game.h"
 #include "core/GameMode.h"
+#include "core/LuaBind.h"
 #include "network/NetworkFunction.h"
+#include "ToluaBindCore.h"
+#include "ToluaBindOrxonox.h"
 #include "tools/Timer.h"
 #include "interfaces/TimeFactorListener.h"
@@ -58,4 +61,8 @@
         this->ccSetTimeFactor_ = 0;
         this->ccPause_ = 0;
+
+        // Tell LuaBind about all tolua interfaces
+        LuaBind::getInstance().addToluaInterface(&tolua_Core_open, "Core");
+        LuaBind::getInstance().addToluaInterface(&tolua_Orxonox_open, "Orxonox");
     }
 
Index: /code/branches/resource/src/orxonox/gui/GUIManager.cc
===================================================================
--- /code/branches/resource/src/orxonox/gui/GUIManager.cc	(revision 3339)
+++ /code/branches/resource/src/orxonox/gui/GUIManager.cc	(revision 3340)
@@ -59,6 +59,5 @@
 #include "core/Core.h"
 #include "core/Clock.h"
-#include "ToluaBindCore.h"
-#include "ToluaBindOrxonox.h"
+#include "core/LuaBind.h"
 
 namespace orxonox
@@ -136,6 +135,5 @@
 
             // do this after 'new CEGUI::Sytem' because that creates the lua state in the first place
-            tolua_Core_open(this->scriptModule_->getLuaState());
-            tolua_Orxonox_open(this->scriptModule_->getLuaState());
+            LuaBind::getInstance().openToluaInterfaces(this->luaState_);
 
             // initialise the basic lua code
@@ -162,8 +160,5 @@
     {
         // destroy our own tolua interfaces
-        lua_pushnil(luaState_);
-        lua_setglobal(luaState_, "Orxonox");
-        lua_pushnil(luaState_);
-        lua_setglobal(luaState_, "Core");
+        LuaBind::getInstance().closeToluaInterfaces(this->luaState_);
 
         singletonRef_s = 0;
