Index: branches/script_engine/src/lib/script_engine/Script.cc
===================================================================
--- branches/script_engine/src/lib/script_engine/Script.cc	(revision 8074)
+++ 	(revision )
@@ -1,222 +1,0 @@
-#include "Script.h"
-
-
-Script::Script()
-{
-  returnCount = argumentCount = 0;
-
-  luaState = lua_open();
-
-  luaopen_base(luaState);
-  luaopen_table(luaState);
-  luaopen_io(luaState);
-  luaopen_string(luaState);
-  luaopen_math(luaState);
-  luaopen_debug(luaState);
-
-}
-
-
-Script::~Script()
-{
-  lua_setgcthreshold(luaState, 0);  // collected garbage
-  lua_close(luaState);
-}
-
-
-bool Script::loadFile(std::string& filename)
- {
-
-   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());
-
-   if(error == 0)
-   {
-     error = lua_pcall(luaState, 0, 0, 0);
-
-     if(error == 0)
-     {
-      currentFile = filename;
-      return true;
-     }
-     else
-     {
-      reportError(error);
-     }
-
-   }
-   else
-   {
-     reportError(error);
-   }
-
-   return false;
- }
-
- bool Script::executeFile()
- {
-   if(currentFile.length() != 0)
-   {
-    int error = lua_pcall(luaState, 0, 0, 0);
-    if( error == 0)
-      return true;
-     else
-      {
-       reportError(error);
-       return false;
-      }
-   }
-   return false;
- }
-
- bool Script::selectFunction(std::string& functionName, int retCount)
- {
-   if(returnCount == 0) //no return values left on the stack
-   {
-   lua_pushlstring(luaState, functionName.c_str(), functionName.size() );
-   lua_gettable(luaState, LUA_GLOBALSINDEX);
-
-   if(lua_isfunction( luaState , -1))
-   {
-     returnCount = retCount;
-     argumentCount = 0;
-     currentFunction = functionName;
-     return true;
-   }
-   else
-    return false;
-   }
-   else
-     printf("there are unremoved return values on the stack. Please remove them first.\n");
- }
-
- //return number of returned values
- bool Script::executeFunction()
- {
-   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
-      argumentCount = 0;
-      return true;
-    }
-   }
-   else
-     printf("Error: no function selected.\n");
- }
-
-
- //overload this function to add different types
- bool Script::pushParam(int 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;
-   }
-
- }
-
-
- bool Script::pushParam(float 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;
-   }
-
- }
-
- 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::getReturnedInt()
- {
-   int returnValue;
-   if(returnCount > 0)
-   {
-     if(lua_isnumber(luaState, -1))
-     {
-       returnValue = (int)lua_tonumber(luaState, -1);
-       returnCount--;
-       lua_pop(luaState,1);
-     }
-   }
-   return returnValue;
- }
-
-
- bool Script::getReturnedBool()
- {
-   bool returnValue;
-   if(returnCount > 0)
-   {
-     if(lua_isboolean(luaState, -1))
-     {
-       returnValue = (bool)lua_toboolean(luaState, -1);
-       returnCount--;
-       lua_pop(luaState,1);
-     }
-   }
-   return returnValue;
- }
-
-float Script::getReturnedFloat()
- {
-   float returnValue;
-   if(returnCount > 0)
-   {
-     if(lua_isnumber(luaState, -1))
-     {
-       returnValue = (float)lua_tonumber(luaState, -1);
-       returnCount--;
-       lua_pop(luaState,1);
-     }
-   }
-   return returnValue;
- }
-
- 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;
- }
-
Index: branches/script_engine/src/lib/script_engine/Script.h
===================================================================
--- branches/script_engine/src/lib/script_engine/Script.h	(revision 8074)
+++ 	(revision )
@@ -1,48 +1,0 @@
-#ifndef _SCRIPT_H
-#define _SCRIPT_H
-
-
-#include <string>
-#include "base_object.h"
-
-#include "luaincl.h"
-
-
-class Script
-{
-  public:
-    Script();
-    ~Script();
-
-    bool loadFile(std::string& filename);
-    bool executeFile();
-
-    lua_State* getLuaState() const{return luaState;}
-
-    bool selectFunction(std::string& functionName, int retCount);
-    bool executeFunction();
-    // push parameters for luafunction
-    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);
-    // get returned values the last return value in lua is the first in c.
-    int   getReturnedInt();//overload this function to get different types
-    bool  getReturnedBool();
-    float getReturnedFloat();
-
-
-  private:
-
-    int reportError(int error);
-
-    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
-    int                returnCount;      //!< Number of return values of the current function
-
-
-
-
-};
-#endif /* _SCRIPT_H */
Index: branches/script_engine/src/lib/script_engine/script.cc
===================================================================
--- branches/script_engine/src/lib/script_engine/script.cc	(revision 8075)
+++ branches/script_engine/src/lib/script_engine/script.cc	(revision 8075)
@@ -0,0 +1,222 @@
+#include "script.h"
+
+
+Script::Script()
+{
+  returnCount = argumentCount = 0;
+
+  luaState = lua_open();
+
+  luaopen_base(luaState);
+  luaopen_table(luaState);
+  luaopen_io(luaState);
+  luaopen_string(luaState);
+  luaopen_math(luaState);
+  luaopen_debug(luaState);
+
+}
+
+
+Script::~Script()
+{
+  lua_setgcthreshold(luaState, 0);  // collected garbage
+  lua_close(luaState);
+}
+
+
+bool Script::loadFile(std::string& filename)
+ {
+
+   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());
+
+   if(error == 0)
+   {
+     error = lua_pcall(luaState, 0, 0, 0);
+
+     if(error == 0)
+     {
+      currentFile = filename;
+      return true;
+     }
+     else
+     {
+      reportError(error);
+     }
+
+   }
+   else
+   {
+     reportError(error);
+   }
+
+   return false;
+ }
+
+ bool Script::executeFile()
+ {
+   if(currentFile.length() != 0)
+   {
+    int error = lua_pcall(luaState, 0, 0, 0);
+    if( error == 0)
+      return true;
+     else
+      {
+       reportError(error);
+       return false;
+      }
+   }
+   return false;
+ }
+
+ bool Script::selectFunction(std::string& functionName, int retCount)
+ {
+   if(returnCount == 0) //no return values left on the stack
+   {
+   lua_pushlstring(luaState, functionName.c_str(), functionName.size() );
+   lua_gettable(luaState, LUA_GLOBALSINDEX);
+
+   if(lua_isfunction( luaState , -1))
+   {
+     returnCount = retCount;
+     argumentCount = 0;
+     currentFunction = functionName;
+     return true;
+   }
+   else
+    return false;
+   }
+   else
+     printf("there are unremoved return values on the stack. Please remove them first.\n");
+ }
+
+ //return number of returned values
+ bool Script::executeFunction()
+ {
+   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
+      argumentCount = 0;
+      return true;
+    }
+   }
+   else
+     printf("Error: no function selected.\n");
+ }
+
+
+ //overload this function to add different types
+ bool Script::pushParam(int 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;
+   }
+
+ }
+
+
+ bool Script::pushParam(float 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;
+   }
+
+ }
+
+ 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::getReturnedInt()
+ {
+   int returnValue;
+   if(returnCount > 0)
+   {
+     if(lua_isnumber(luaState, -1))
+     {
+       returnValue = (int)lua_tonumber(luaState, -1);
+       returnCount--;
+       lua_pop(luaState,1);
+     }
+   }
+   return returnValue;
+ }
+
+
+ bool Script::getReturnedBool()
+ {
+   bool returnValue;
+   if(returnCount > 0)
+   {
+     if(lua_isboolean(luaState, -1))
+     {
+       returnValue = (bool)lua_toboolean(luaState, -1);
+       returnCount--;
+       lua_pop(luaState,1);
+     }
+   }
+   return returnValue;
+ }
+
+float Script::getReturnedFloat()
+ {
+   float returnValue;
+   if(returnCount > 0)
+   {
+     if(lua_isnumber(luaState, -1))
+     {
+       returnValue = (float)lua_tonumber(luaState, -1);
+       returnCount--;
+       lua_pop(luaState,1);
+     }
+   }
+   return returnValue;
+ }
+
+ 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;
+ }
+
Index: branches/script_engine/src/lib/script_engine/script.h
===================================================================
--- branches/script_engine/src/lib/script_engine/script.h	(revision 8075)
+++ branches/script_engine/src/lib/script_engine/script.h	(revision 8075)
@@ -0,0 +1,48 @@
+#ifndef _SCRIPT_H
+#define _SCRIPT_H
+
+
+#include <string>
+#include "base_object.h"
+
+#include "luaincl.h"
+
+
+class Script
+{
+  public:
+    Script();
+    ~Script();
+
+    bool loadFile(std::string& filename);
+    bool executeFile();
+
+    lua_State* getLuaState() const{return luaState;}
+
+    bool selectFunction(std::string& functionName, int retCount);
+    bool executeFunction();
+    // push parameters for luafunction
+    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);
+    // get returned values the last return value in lua is the first in c.
+    int   getReturnedInt();//overload this function to get different types
+    bool  getReturnedBool();
+    float getReturnedFloat();
+
+
+  private:
+
+    int reportError(int error);
+
+    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
+    int                returnCount;      //!< Number of return values of the current function
+
+
+
+
+};
+#endif /* _SCRIPT_H */
