Index: branches/script_engine/src/lib/script_engine/Makefile.am
===================================================================
--- branches/script_engine/src/lib/script_engine/Makefile.am	(revision 8021)
+++ branches/script_engine/src/lib/script_engine/Makefile.am	(revision 8032)
@@ -1,2 +1,4 @@
+MAINSRCDIR=../..
+include $(MAINSRCDIR)/defs/include_paths.am
 
 INCLUDES= -I../../../extern_libs
Index: branches/script_engine/src/lib/script_engine/Script.cc
===================================================================
--- branches/script_engine/src/lib/script_engine/Script.cc	(revision 8021)
+++ branches/script_engine/src/lib/script_engine/Script.cc	(revision 8032)
@@ -4,4 +4,5 @@
 Script::Script()
 {
+
   luaState = lua_open();
 
@@ -21,2 +22,74 @@
   lua_close(luaState);
 }
+
+
+bool Script::loadFile(std::string& filename)
+ {
+   int error = luaL_loadfile (luaState, filename.c_str());
+
+   if(error == 0)
+   {
+     return true;
+   }
+   else
+   {
+     switch(error)
+     {
+     case LUA_ERRSYNTAX :
+       printf("Syntax error in file %s \n",filename.c_str() );
+
+     case LUA_ERRMEM :
+       printf("Memory allocation error in file %s", filename.c_str() );
+     }
+   }
+
+ }
+
+
+
+ void Script::selectFunction(std::string& functionName, int retCount)
+ {
+   returnCount = retCount;
+   currentFunction = functionName;
+   lua_pushlstring(luaState, currentFunction.c_str(), currentFunction.size() );
+   lua_gettable(luaState, LUA_GLOBALSINDEX);
+ }
+
+ //return number of returned values
+ int  Script::executeFunction()
+ {
+    lua_call(luaState, argumentCount, returnCount);
+ }
+
+
+ //overload this function to add different types
+ bool Script::pushParam(int param, std::string& toFunction)
+ {
+   if(currentFunction.compare(toFunction) != 0)
+   {
+    lua_pushnumber(luaState,  param);
+    return true;
+   }
+   else
+   {
+     printf("Couldn't add parameter because the wrong function is selected: %s instead of %s", currentFunction.c_str(), toFunction.c_str());
+     return false;
+   }
+
+ }
+
+
+ bool Script::pushParam(float param, std::string& toFunction)
+ {
+   if(currentFunction.compare(toFunction) != 0)
+   {
+     lua_pushnumber(luaState, param);
+     return true;
+   }
+   else
+   {
+     printf("Couldn't add parameter because the wrong function is selected: %s instead of %s", currentFunction.c_str(), toFunction.c_str());
+     return false;
+   }
+
+ }
Index: branches/script_engine/src/lib/script_engine/Script.h
===================================================================
--- branches/script_engine/src/lib/script_engine/Script.h	(revision 8021)
+++ branches/script_engine/src/lib/script_engine/Script.h	(revision 8032)
@@ -1,6 +1,10 @@
+#ifndef _SCRIPT_H
+#define _SCRIPT_H
+
+
 #include <string>
+#include "base_object.h"
 
 #include "luaincl.h"
-#include "lunar.h"
 
 
@@ -11,11 +15,12 @@
     ~Script();
 
-    void setFile();
+    bool loadFile(std::string& filename);
 
-    void insertObject();
-    void registerClass();
+    lua_State* getLuaState() const{return luaState;}
 
-    void executeLuaFunction();
-    void addParam();
+    void selectFunction(std::string& functionName, int retCount);
+    int  executeFunction(); //return number of returned values
+    bool pushParam(int param, std::string& toFunction);//overload this function to add different types
+    bool pushParam(float param, std::string& toFunction);
 
 
@@ -23,6 +28,8 @@
   private:
 
-    lua_State*         luaState; //!< The lua_State that the Script works on
-
+    lua_State*         luaState;         //!< The lua_State that the Script works on
+    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
 
 
@@ -30,2 +37,3 @@
 
 };
+#endif /* _SCRIPT_H */
Index: branches/script_engine/src/lib/script_engine/lunar.h
===================================================================
--- branches/script_engine/src/lib/script_engine/lunar.h	(revision 8021)
+++ branches/script_engine/src/lib/script_engine/lunar.h	(revision 8032)
@@ -1,6 +1,10 @@
+#ifndef _LUNAR_H
+#define _LUNAR_H
+
 #include <string>
-
+#include "Script.h"
 
 #include "luaincl.h"
+
 
 
@@ -10,4 +14,11 @@
       typedef int (T::*mfp)(lua_State *L);
       typedef struct { const char *name; mfp mfunc; } RegType;
+
+
+      static void Register(Script* script)
+      {
+        if(script != NULL)
+          Register(script->getLuaState());
+      }
 
       static void Register(lua_State *L) {
@@ -221,3 +232,4 @@
     };
 
-
+#endif /* _LUNAR_H */
+
