Index: branches/script_engine/src/lib/script_engine/script.cc
===================================================================
--- branches/script_engine/src/lib/script_engine/script.cc	(revision 8288)
+++ branches/script_engine/src/lib/script_engine/script.cc	(revision 8289)
@@ -23,5 +23,4 @@
   luaopen_math(luaState);
   luaopen_debug(luaState);
-
   if (root != NULL)
     this->loadParams(root);
@@ -77,10 +76,12 @@
      else
      {
-      reportError(error);
-     }
-
-   }
-   else
-   {
+       printf("ERROR while loading file %s: ",filename.c_str());
+       reportError(error);
+     }
+
+   }
+   else
+   {
+     printf("ERROR while loading file %s: ",filename.c_str());
      reportError(error);
    }
@@ -92,4 +93,6 @@
  void Script::addObject(const std::string& className, const std::string& objectName)
  {
+   printf("Script: I am about to add %s of class %s\n",objectName.c_str(),className.c_str());
+   
    BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
    WorldObject tmpObj;
@@ -162,5 +165,9 @@
     if(error != 0)
     {
+     printf("ERROR while executing function %s: \n",currentFunction.c_str());
      reportError(error);
+     //clean up
+     currentFunction.assign(""); 
+     argumentCount = returnCount = 0;
      return false;
     }
@@ -174,4 +181,6 @@
    else
      printf("Error: no function selected.\n");
+   
+   return false;
  }
 
@@ -296,7 +305,7 @@
   fprintf(stderr, "ERROR: %s\n", msg);
   lua_pop(luaState, 1);
+ }
   return error;
  }
- }
 
 
Index: branches/script_engine/src/lib/script_engine/script_class.h
===================================================================
--- branches/script_engine/src/lib/script_engine/script_class.h	(revision 8288)
+++ branches/script_engine/src/lib/script_engine/script_class.h	(revision 8289)
@@ -61,5 +61,5 @@
     virtual int insertObject(Script* L, BaseObject* obj, bool gc=false)
     {
-      Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);
+      return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);
     }
 
Index: branches/script_engine/src/lib/script_engine/script_manager.cc
===================================================================
--- branches/script_engine/src/lib/script_engine/script_manager.cc	(revision 8288)
+++ branches/script_engine/src/lib/script_engine/script_manager.cc	(revision 8289)
@@ -1,4 +1,6 @@
 #include <string>
 #include <list>
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
 
 
@@ -19,5 +21,4 @@
 {
   this->setName("ScriptManager");
-  printf("ScriptManager created\n");
   this->scripts = NULL;
   this->triggers = NULL;
@@ -74,5 +75,5 @@
   LOAD_PARAM_START_CYCLE(triggers, object);
   {
-    new ScriptTrigger(object);PRINTF(0)("test output from createtriggers\n");
+    new ScriptTrigger(object);
   }
   LOAD_PARAM_END_CYCLE(object);
Index: branches/script_engine/src/story_entities/game_world.cc
===================================================================
--- branches/script_engine/src/story_entities/game_world.cc	(revision 8288)
+++ branches/script_engine/src/story_entities/game_world.cc	(revision 8289)
@@ -137,4 +137,7 @@
   PhysicsEngine::getInstance();
   CREngine::getInstance();
+  
+  State::setScriptManager(&this->scriptManager);
+
 }
 
@@ -146,5 +149,6 @@
 ErrorMessage GameWorld::loadData()
 {
-  this->displayLoadScreen();
+  this->displayLoadScreen();  State::setScriptManager(&this->scriptManager);
+
 
   PRINTF(0)("Loading the GameWorld\n");
@@ -189,5 +193,5 @@
   Account *b = new Account(30);
   b->setName("b");
-  
+  printf("ScriptManager created by game world\n");
   LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams);
 
@@ -229,6 +233,4 @@
   this->bRunning = true;
 
-  State::setScripManager(&this->scriptManager);
-
   this->run();
 }
@@ -241,5 +243,5 @@
 {
   PRINTF(3)("GameWorld::stop() - got stop signal\n");
-  State::setScripManager(NULL);
+  State::setScriptManager(NULL);
   this->bRunning = false;
 }
Index: branches/script_engine/src/util/state.h
===================================================================
--- branches/script_engine/src/util/state.h	(revision 8288)
+++ branches/script_engine/src/util/state.h	(revision 8289)
@@ -96,7 +96,7 @@
 
   ////////////////////
-  /// SCRIP_ENGINE ///
+  /// SCRIPT_ENGINE ///
   ////////////////////
-  static void setScripManager(ScriptManager* scriptManager) { State::scriptManager = scriptManager; };
+  static void setScriptManager(ScriptManager* scriptManager) { State::scriptManager = scriptManager; };
   static ScriptManager* getScriptManager() { return State::scriptManager; };
 
Index: branches/script_engine/src/world_entities/script_trigger.cc
===================================================================
--- branches/script_engine/src/world_entities/script_trigger.cc	(revision 8288)
+++ branches/script_engine/src/world_entities/script_trigger.cc	(revision 8289)
@@ -18,5 +18,4 @@
   loadParams(root);
 
-  printf("scripttrigger generated\n");
 }
 
@@ -95,5 +94,4 @@
   if( this->distance(target) < radius)
  {
-   printf("SCRIPTTRIGGER: condition met\n");
   if(!callOnce)
    {
@@ -102,11 +100,10 @@
   else if(callOnce && !scriptCalled)
   {
-    printf("action should be executed\n");
    executeAction();
    scriptCalled = true;
   }
  }
- else
-   printf("SCRIPTTRIGGER: target out of range\n");
+ //else
+   //printf("SCRIPTTRIGGER: target out of range\n");
 
 }
@@ -118,8 +115,8 @@
      {
        testScriptingFramework();
-     if(!(script->selectFunction(this->functionName,0)) )
+     /*if(!(script->selectFunction(this->functionName,0)) )
        printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
      if( !(script->executeFunction()) )
-       printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());
+       printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());*/
      }
 }
@@ -128,10 +125,14 @@
 void ScriptTrigger::setScript(const std::string& file)
 {
+ 
   ScriptManager* scriptManager = State::getScriptManager();
   if (scriptManager != NULL)
   {
+    
     script = scriptManager->getScriptByFile(file);
     if(script != NULL)
+    {
       scriptIsOk = true;
+    }
   }
 }
@@ -173,4 +174,5 @@
 
    script->pushParam(3.14159,main);
+   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
    script->executeFunction();
 
@@ -187,5 +189,5 @@
    printf("main returned %i\n",ret);
 
-      //printf("-------------------------- top of the stack:%i\n",lua_gettop(script.getLuaState()));
+   printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState()));
       //execute a 2nd function
    printf("----------- test -----------\n");
