Index: /branches/script_engine/src/lib/script_engine/Script.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/Script.cc	(revision 8044)
+++ /branches/script_engine/src/lib/script_engine/Script.cc	(revision 8045)
@@ -4,5 +4,4 @@
 Script::Script()
 {
-
   returnCount = argumentCount = 0;
 
@@ -15,5 +14,4 @@
   luaopen_math(luaState);
   luaopen_debug(luaState);
-
 
 }
@@ -30,4 +28,7 @@
  {
 
+   if(currentFile.length() != 0)
+     printf("Could not load %s because an other file is already loaded: %s\n",filename.c_str(), currentFile.c_str());
+
    int error = luaL_loadfile (luaState, filename.c_str());
 
@@ -37,10 +38,13 @@
 
      if(error == 0)
+     {
+      currentFile = filename;
       return true;
+     }
      else
      {
       reportError(error);
-      return false;
      }
+
    }
    else
@@ -54,17 +58,21 @@
  bool Script::executeFile()
  {
-   int error = lua_pcall(luaState, 0, LUA_MULTRET, 0);
-   if( error== 0)
-     return true;
-   else
+   if(currentFile.length() != 0)
    {
-     reportError(error);
-     return false;
+    int error = lua_pcall(luaState, 0, 0, 0);
+    if( error == 0)
+      return true;
+     else
+      {
+       reportError(error);
+       return false;
+      }
    }
-
+   return false;
  }
 
- void Script::selectFunction(std::string& functionName, int retCount)
+ bool Script::selectFunction(std::string& functionName, int retCount)
  {
+
    returnCount = retCount;
    argumentCount = 0;
@@ -72,10 +80,34 @@
    lua_pushlstring(luaState, currentFunction.c_str(), currentFunction.size() );
    lua_gettable(luaState, LUA_GLOBALSINDEX);
+
+  /* if(lua_isfunction( luaState , -1))
+   {
+     return true;
+   }
+   else
+   return false;*/
+   return true;
  }
 
  //return number of returned values
- void Script::executeFunction()
+ bool Script::executeFunction()
  {
-    lua_pcall(luaState, argumentCount, returnCount,0);
+   if(currentFunction.length() != 0 )
+   {
+    int error = lua_pcall(luaState, argumentCount, returnCount,0);
+    if(error != 0)
+    {
+     reportError(error);
+     return false;
+    }
+    else
+    {
+      currentFunction.assign("");//a function gets unusable after beeing called for the first time
+      returnCount = argumentCount = 0;
+      return true;
+    }
+   }
+   else
+     printf("Error: no function selected.\n");
  }
 
@@ -115,4 +147,20 @@
  }
 
+ bool Script::pushParam(double param, std::string& toFunction)
+ {
+   if(currentFunction.compare(toFunction) == 0)
+   {
+     lua_pushnumber(luaState,(lua_Number) param);
+     argumentCount++;
+     return true;
+   }
+   else
+   {
+     printf("Couldn't add parameter because the wrong function is selected: %s instead of %s\n", currentFunction.c_str(), toFunction.c_str());
+     return false;
+   }
+
+ }
+
  int Script::reportError(int error)
  {
Index: /branches/script_engine/src/lib/script_engine/Script.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/Script.h	(revision 8044)
+++ /branches/script_engine/src/lib/script_engine/Script.h	(revision 8045)
@@ -20,8 +20,9 @@
     lua_State* getLuaState() const{return luaState;}
 
-    void selectFunction(std::string& functionName, int retCount);
-    void  executeFunction(); //return number of returned values
+    bool selectFunction(std::string& functionName, int retCount);
+    bool executeFunction();
     bool pushParam(int param, std::string& toFunction);//overload this function to add different types
     bool pushParam(float param, std::string& toFunction);
+    bool pushParam(double param, std::string& toFunction);
 
 
@@ -33,4 +34,5 @@
 
     lua_State*         luaState;         //!< The lua_State that the Script works on
+    std::string        currentFile;      //!< The file that is loaded in the script
     std::string        currentFunction;  //!< The name of the current active function (the one that gets the pushed parameter)
     int                argumentCount;    //!< Number of arguments for the current function
Index: /branches/script_engine/src/lib/script_engine/account.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/account.cc	(revision 8044)
+++ /branches/script_engine/src/lib/script_engine/account.cc	(revision 8045)
@@ -66,4 +66,6 @@
     {
       Script script;
+
+      // Register classes with the script
       Lunar<Account>::Register(&script);
       Lunar<Object>::Register(&script);
@@ -73,4 +75,5 @@
       Account *b = new Account(30);
 
+      // Add instances to the script
       Lunar<Object>::insertObject(&script,obj,"Obj",true);
       Lunar<Account>::insertObject(&script,&a,"a",false);
@@ -81,11 +84,11 @@
 
       if(script.loadFile(file))
-        printf("file %s succefully loaded\n", file.c_str());
+        printf("File %s succefully loaded\n", file.c_str());
 
       //script.executeFile();
 
       std::string main("main");
-      script.selectFunction(main,1);
-      script.pushParam(3,main);
+      script.selectFunction(main,0);
+      script.pushParam(3.14159,main);
       script.executeFunction();
 
