Index: /branches/script_engine/src/lib/script_engine/account.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/account.cc	(revision 8084)
+++ /branches/script_engine/src/lib/script_engine/account.cc	(revision 8085)
@@ -91,4 +91,5 @@
     {
       Script script;
+      printf("-------------------------- top of the stack:%i\n",lua_gettop(script.getLuaState()));
 
       // Register classes with the script
@@ -104,13 +105,13 @@
       Lunar<Account>::insertObject(&script,&a,"a",false);
       Lunar<Account>::insertObject(&script,b,"b",true);
-
-
+       printf("-------------------------- top of the stack:%i\n",lua_gettop(script.getLuaState()));
+      //Load a file
       std::string file(argv[1]);
 
       if(script.loadFile(file))
         printf("File %s succefully loaded\n", file.c_str());
-
-      //script.executeFile();
-
+      printf("-------------------------- top of the stack:%i\n",lua_gettop(script.getLuaState()));
+      //execute a function
+      printf("----------- main -----------\n");
       std::string main("main");
       if( script.selectFunction(main,3))
@@ -131,6 +132,17 @@
       int ret = script.getReturnedInt();
       printf("main returned %i\n",ret);
+
+      printf("-------------------------- top of the stack:%i\n",lua_gettop(script.getLuaState()));
+      //execute a 2nd function
+      printf("----------- test -----------\n");
+      std::string test("test");
+      if( script.selectFunction(test,0))
+       printf("function %s selected\n",test.c_str());
+
+      script.executeFunction();
+
       
       //if(argc>1) lua_dofile(script.getLuaState(), argv[1]);
+      printf("-------------------------- top of the stack:%i\n",lua_gettop(script.getLuaState()));
 
       return 0;
Index: /branches/script_engine/src/lib/script_engine/lunartest2.lua
===================================================================
--- /branches/script_engine/src/lib/script_engine/lunartest2.lua	(revision 8084)
+++ /branches/script_engine/src/lib/script_engine/lunartest2.lua	(revision 8085)
@@ -14,4 +14,10 @@
 
 getmetatable(Account).__index = parent
+
+
+function test()
+io.write("Hi i'm test\n")
+end
+
 
 function main(arg)
Index: /branches/script_engine/src/lib/script_engine/script.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/script.cc	(revision 8084)
+++ /branches/script_engine/src/lib/script_engine/script.cc	(revision 8085)
@@ -29,5 +29,8 @@
 
    if(currentFile.length() != 0)
+   { 
      printf("Could not load %s because an other file is already loaded: %s\n",filename.c_str(), currentFile.c_str());
+     return false;
+    }
 
    int error = luaL_loadfile (luaState, filename.c_str());
@@ -74,5 +77,5 @@
  bool Script::selectFunction(std::string& functionName, int retCount)
  {
-   if(returnCount == 0) //no return values left on the stack
+   if(returnCount == 0 && currentFunction.length() == 0) //no return values left on the stack and no other function selected
    {
    lua_pushlstring(luaState, functionName.c_str(), functionName.size() );
@@ -90,5 +93,6 @@
    }
    else
-     printf("there are unremoved return values on the stack. Please remove them first.\n");
+     printf("There is an other function active ( %s ) or there are unremoved return values on the stack. Please remove them first.\n",currentFunction.c_str());
+   return false;
  }
 
@@ -214,9 +218,12 @@
  int Script::reportError(int error)
  {
- const char *msg = lua_tostring(luaState, -1);
- if (msg == NULL) msg = "(error with no message)";
- fprintf(stderr, "ERROR: %s\n", msg);
- lua_pop(luaState, 1);
- return error;
- }
-
+ if(error != 0)
+ {
+  const char *msg = lua_tostring(luaState, -1);
+  if (msg == NULL) msg = "(error with no message)";
+  fprintf(stderr, "ERROR: %s\n", msg);
+  lua_pop(luaState, 1);
+  return error;
+ }
+ }
+
Index: /branches/script_engine/src/lib/script_engine/script_manager.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/script_manager.cc	(revision 8084)
+++ /branches/script_engine/src/lib/script_engine/script_manager.cc	(revision 8085)
@@ -0,0 +1,3 @@
+
+#include "script.h"
+#include "script_manager.h"
Index: /branches/script_engine/src/lib/script_engine/script_manager.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/script_manager.h	(revision 8084)
+++ /branches/script_engine/src/lib/script_engine/script_manager.h	(revision 8085)
@@ -0,0 +1,25 @@
+#ifndef _SCRIPT_MANAGER_H
+#define _SCRIPT_MNAGER_H
+
+
+#include <string>
+#include "base_object.h"
+
+#include "luaincl.h"
+
+
+
+class ScriptManager
+{
+ public:
+
+
+
+
+
+ private:
+
+
+
+};
+#endif
