Index: trunk/src/lib/script_engine/Makefile.am
===================================================================
--- trunk/src/lib/script_engine/Makefile.am	(revision 9298)
+++ trunk/src/lib/script_engine/Makefile.am	(revision 9869)
@@ -16,6 +16,7 @@
                 script_manager.cc \
 		script_class.cc \
-		script_method.cc
-		
+		script_method.cc \
+		executor_lua_state.cc
+
 AM_CPPFLAGS= @LUA_INCLUDES@
 
@@ -25,5 +26,6 @@
                 script_manager.h \
 		script_class.h \
-		script_method.h
+		script_method.h \
+		executor_lua_state.h
 
 
Index: trunk/src/lib/script_engine/executor_lua_state.cc
===================================================================
--- trunk/src/lib/script_engine/executor_lua_state.cc	(revision 9869)
+++ trunk/src/lib/script_engine/executor_lua_state.cc	(revision 9869)
@@ -0,0 +1,28 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: ...
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
+
+#include "executor_lua_state.h"
+
+#include "lunar.h"
+
+std::string temp[7];
+
+
+template<typename type> type fromLua(lua_State* state, int index) { type *obj = Lunar<type>::check(state, 1); lua_remove(state, 1); return obj; };
+template<typename type> void toLua(lua_State* state, type value) { Lunar<type>::push(state, value, false); };
+
+template<> const std::string& fromLua<const std::string&>(lua_State* state, int index) { temp[index] = lua_tostring(state, index); return temp[index]; };
Index: trunk/src/lib/script_engine/executor_lua_state.h
===================================================================
--- trunk/src/lib/script_engine/executor_lua_state.h	(revision 9869)
+++ trunk/src/lib/script_engine/executor_lua_state.h	(revision 9869)
@@ -0,0 +1,105 @@
+/*!
+ * @file executor_lua_state.h
+ * Definition of a Executor that takes lua_State* as input.
+ */
+
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+
+
+#ifndef __EXECUTOR_LUA_STATE_H_
+#define __EXECUTOR_LUA_STATE_H_
+
+
+#include "executor/executor_generic.h"
+
+#include "luaincl.h"
+
+#ifdef FUNCTOR_CALL_TYPE
+ #undef FUNCTOR_CALL_TYPE
+#endif
+//! Define the Functor call type as lua_State*.
+#define FUNCTOR_CALL_TYPE lua_State*
+
+/**
+ * @brief Converts a lua_State into any type.
+ * @param state the State to get the value from.
+ * @param index the position inside of the lua_State to get the value from.
+ * @returns The value if found.
+ */
+template<typename type> type fromLua(lua_State* state, int index);
+/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
+template<> inline bool fromLua<bool>(lua_State* state, int index) { return lua_toboolean(state, index); };
+/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
+template<> inline int fromLua<int>(lua_State* state, int index) { return (int)lua_tonumber(state, index); };
+/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
+template<> inline unsigned int fromLua<unsigned int>(lua_State* state, int index) { return (unsigned int)lua_tonumber(state, index); };
+/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
+template<> inline float fromLua<float>(lua_State* state, int index) { return (float)lua_tonumber(state, index); };
+/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
+template<> inline char fromLua<char>(lua_State* state, int index) { return (char)lua_tonumber(state, index); };
+/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
+template<> const std::string& fromLua<const std::string&>(lua_State* state, int index);
+
+
+/**
+ * @brief writes a value into a lua_State.
+ * @param state the state to write into.
+ * @param value the Value of type to write into the State.
+ */
+template<typename type> void toLua(lua_State* state, type value);
+/** @see template<typename type> void toLua(lua_State* state, type value) */
+template<> inline void toLua<bool>(lua_State* state, bool value) { lua_pushboolean(state, (int) value); };
+/** @see template<typename type> void toLua(lua_State* state, type value) */
+template<> inline void toLua<int>(lua_State* state, int value)  { lua_pushnumber(state, (lua_Number) value); };
+/** @see template<typename type> void toLua(lua_State* state, type value) */
+template<> inline void toLua<unsigned int>(lua_State* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };
+/** @see template<typename type> void toLua(lua_State* state, type value) */
+template<> inline void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); };
+/** @see template<typename type> void toLua(lua_State* state, type value) */
+template<> inline void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); };
+/** @see template<typename type> void toLua(lua_State* state, type value) */
+template<> inline void toLua<const std::string&>(lua_State* state, const std::string& value) { lua_pushstring (state, value.c_str()); }
+
+
+
+//! A Class, that evaluates a lua_State and converts indices into different Types.
+template<> class ExecutorEvaluater <lua_State*>
+{
+public:
+  /** @brief Executes the Evaluater
+   * @param CallValue the Value that should be converted
+   * @param defaults the default Values.
+   */
+  template <typename ToType, int index>
+  static ToType getValue(lua_State*& CallValue, const MultiType* const defaults)
+  {
+    return (fromLua<ToType>(CallValue, index+1));
+  }
+  /**
+   * @param state the state to write into
+   * @param value the Value to write there.
+   */
+  template <typename FromType>
+  static void storeRet(lua_State*& state, FromType value)
+  {
+    toLua<FromType>(state, value);
+  }
+  /** @returns the Null Value of a lua_State*, namely (pointer-type) NULL */
+  static lua_State*& defaultValue() { static lua_State* nullState; return nullState; };
+};
+
+#endif /* __EXECUTOR_LUA_STATE_H_ */
Index: trunk/src/lib/script_engine/lunar.h
===================================================================
--- trunk/src/lib/script_engine/lunar.h	(revision 9298)
+++ trunk/src/lib/script_engine/lunar.h	(revision 9869)
@@ -16,5 +16,5 @@
   userdataType;
 public:
-  typedef Executor* mfp;
+  typedef Executor<lua_State*>* mfp;
   typedef struct { const char *name; mfp mfunc; }
   RegType;
@@ -184,8 +184,7 @@
     lua_remove(L, 1);  // remove self so member function args start at index 1
     // get member function from upvalue
-    Executor *l = static_cast<Executor*>(lua_touserdata(L, lua_upvalueindex(1)));
-    int value;
-    (*l)(obj, value, L);  // call member function
-    return value;
+    mfp l = static_cast<mfp>(lua_touserdata(L, lua_upvalueindex(1)));
+    (*l)(obj, L);  // call member function
+    return l->hasRetVal()? 1 : 0;
   }
 
Index: trunk/src/lib/script_engine/script.cc
===================================================================
--- trunk/src/lib/script_engine/script.cc	(revision 9298)
+++ trunk/src/lib/script_engine/script.cc	(revision 9869)
@@ -18,20 +18,22 @@
 #include "luaincl.h"
 #include "debug.h"
-#include "util/loading/resource_manager.h"
-
+
+#include "loading/resource_manager.h"
 #include "loading/load_param.h"
 #include "parser/tinyxml/tinyxml.h"
 
-#include "class_list.h"
-CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT,
-                    addMethod("addObject", ExecutorLua2<Script,const std::string&, const std::string& >(&Script::addObject))
-                    ->addMethod("registerClass", ExecutorLua1<Script,const std::string&>(&Script::registerClass))
-                    ->addMethod("selectFunction", ExecutorLua2ret<Script, bool, const std::string&, int >(&Script::selectFunction))
-                    ->addMethod("executeFunction", ExecutorLua0ret<Script,bool >(&Script::executeFunction))
+ObjectListDefinition(Script);
+
+CREATE_SCRIPTABLE_CLASS(Script,
+                    addMethod("addObject", Executor2<Script, lua_State*,const std::string&, const std::string& >(&Script::addObject))
+                    ->addMethod("registerClass", Executor1<Script, lua_State*,const std::string&>(&Script::registerClass))
+                    ->addMethod("selectFunction", Executor2ret<Script, lua_State*, bool, const std::string&, int >(&Script::selectFunction))
+                    ->addMethod("executeFunction", Executor0ret<Script, lua_State*,bool >(&Script::executeFunction))
                      );
+
 
 Script::Script(const TiXmlElement* root)
 {
-  this->setClassID(CL_SCRIPT, "Script");
+  this->registerObject(this, Script::_objectList);
 
   returnCount = argumentCount = 0;
@@ -52,5 +54,5 @@
 Script::Script(const std::string& filename)
 {
-  this->setClassID(CL_SCRIPT, "Script");
+  this->registerObject(this, Script::_objectList);
 
   returnCount = argumentCount = 0;
@@ -64,5 +66,5 @@
   luaopen_math(luaState);
   luaopen_debug(luaState);
-  
+
   this->loadFile(filename);
 
@@ -98,10 +100,10 @@
 bool Script::loadFile(const std::string& filename)
  {
-   std::string filedest(ResourceManager::getInstance()->getDataDir());
-   filedest += "scripts/" + filename;
-   
+   std::string filedest(Resources::ResourceManager::getInstance()->mainGlobalPath().name());
+   filedest += "/scripts/" + filename;
+
    this->addThisScript();
    this->registerStandartClasses();
-   
+
    if(currentFile.length() != 0)
    {
@@ -142,5 +144,5 @@
    //printf(("Script %s: I am about to add %s of class %s\n",this->getName(),objectName.c_str(),className.c_str());
 
-   BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
+   ScriptClass* scriptClass = ScriptClass::objectList().getObject(className);
   // printf(("The script class for %s is at %p \n",className.c_str(),scriptClass);
    WorldObject tmpObj;
@@ -150,12 +152,12 @@
      if( !classIsRegistered(className) )
      {
-     static_cast<ScriptClass*>(scriptClass)->registerClass(this);
-     }
-
-     BaseObject* object = ClassList::getObject(objectName, className);
+       scriptClass->registerClass(this);
+     }
+
+     BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
     // printf(("%s is at %p \n",objectName.c_str(),object);
      if (object != NULL && !objectIsAdded(objectName))
      {
-        static_cast<ScriptClass*>(scriptClass)->insertObject(this, object, false);
+        scriptClass->insertObject(this, object, false);
         tmpObj.name = objectName;
         registeredObjects.push_back(tmpObj);
@@ -169,5 +171,5 @@
  bool Script::executeFile()
  {
-   PRINT(2)("WARNING: script.executeFile is not implemented yet\n");
+   PRINTF(2)("script.executeFile is not implemented yet\n");
    /*if(currentFile.length() != 0)
    {
@@ -214,5 +216,5 @@
     if(error != 0)
     {
-      printf("SCRIPT %s : ERROR: Failed to execute function %s: \n",currentFile.c_str(),currentFunction.c_str());
+      PRINTF(1)("Script '%s' : Failed to execute function '%s': \n",currentFile.c_str(),currentFunction.c_str());
      reportError(error);
      //clean up
@@ -229,5 +231,5 @@
    }
    else
-     printf("SCRIPT %s : ERROR: no function selected.\n",currentFile.c_str());
+     PRINTF(1)("SCRIPT '%s' : no function selected.\n",currentFile.c_str());
 
    return false;
@@ -295,5 +297,5 @@
        lua_remove(luaState,-1*returnCount);
        returnCount--;
-       
+
      }
    }
@@ -352,9 +354,10 @@
 void Script::addThisScript()
 {
-  BaseObject* scriptClass = ClassList::getObject("Script", CL_SCRIPT_CLASS);
-   if (scriptClass != NULL)
-   {
-     static_cast<ScriptClass*>(scriptClass)->registerClass(this);
-     static_cast<ScriptClass*>(scriptClass)->insertObject(this, this,"thisscript", false);
+  ScriptClass* scriptClass = ScriptClass::objectList().getObject("Script");
+
+  if (scriptClass != NULL)
+   {
+     scriptClass->registerClass(this);
+     scriptClass->insertObject(this, this,"thisscript", false);
    }
 }
@@ -375,5 +378,5 @@
  {
    bool success = false;
-   
+
    //this->registerClass(std::string("Vector"));
     this->registerClass("ScriptTrigger");
@@ -382,10 +385,11 @@
    return success;
  }
- 
- 
+
+
  void Script::registerClass( const std::string& className)
  {
-   BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
+   ScriptClass* scriptClass = ScriptClass::objectList().getObject(className);
    //printf(("The script class for %s is at %p \n",className.c_str(),scriptClass);
+
    WorldObject tmpObj;
    if (scriptClass != NULL)
@@ -400,5 +404,5 @@
      }
    }
- 
+
  }
 
Index: trunk/src/lib/script_engine/script.h
===================================================================
--- trunk/src/lib/script_engine/script.h	(revision 9298)
+++ trunk/src/lib/script_engine/script.h	(revision 9869)
@@ -22,4 +22,5 @@
 class Script : public BaseObject
 {
+  ObjectListDeclaration(Script);
   public:
     Script(const TiXmlElement* root = NULL);
@@ -33,5 +34,5 @@
     bool loadFile(const std::string& filename);
     void addObject( const std::string& className,const std::string& objectName);
-    void registerClass(const std::string& className);                           //!< Register a class but dont add any instances 
+    void registerClass(const std::string& className);                           //!< Register a class but dont add any instances
 
     /// QUERRYING
Index: trunk/src/lib/script_engine/script_class.cc
===================================================================
--- trunk/src/lib/script_engine/script_class.cc	(revision 9298)
+++ trunk/src/lib/script_engine/script_class.cc	(revision 9869)
@@ -19,13 +19,14 @@
 #include <cassert>
 
+ObjectListDefinition(ScriptClass);
 /**
  * @brief standard constructor
  * @todo this constructor is not jet implemented - do it
 */
-ScriptClass::ScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods)
-    : BaseObject(name)
+ScriptClass::ScriptClass(const std::string& name, const ClassID& classID, ScriptMethod* scriptMethods)
+    : BaseObject(name), _classID(classID)
 {
   assert(scriptMethods != NULL);
-  this->setClassID(CL_SCRIPT_CLASS, "ScriptClass");
+  this->registerObject(this, ScriptClass::_objectList);
 
   this->_classID = classID;
Index: trunk/src/lib/script_engine/script_class.h
===================================================================
--- trunk/src/lib/script_engine/script_class.h	(revision 9298)
+++ trunk/src/lib/script_engine/script_class.h	(revision 9869)
@@ -18,26 +18,24 @@
  * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
  */
-#define CREATE_SCRIPTABLE_CLASS(CLASS_NAME, CLASS_ID, SCRIPT_METHODS) \
-    tScriptClass<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_ID, (new ScriptMethod)->SCRIPT_METHODS)
+#define CREATE_SCRIPTABLE_CLASS(CLASS_NAME, SCRIPT_METHODS) \
+    tScriptClass<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_NAME::staticClassID(), (new ScriptMethod)->SCRIPT_METHODS)
 
 
 //! A class for ...
-class ScriptClass : protected BaseObject
+class ScriptClass : public BaseObject
 {
+  ObjectListDeclaration(ScriptClass);
 
 public:
   virtual ~ScriptClass();
 
-  bool operator==(const std::string& name) { return (this->getName() == name); }
-  bool operator==(ClassID classID) { return (this->_classID == classID); }
-
   virtual void registerClass(Script* script) = 0;
   virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) = 0;
-  virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0; 
+  virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0;
 
   const ScriptMethod* scriptMethods() const { return this->_scriptMethods; }
 
 protected:
-  ScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods);
+  ScriptClass(const std::string& name, const ClassID& classID, ScriptMethod* scriptMethods);
 
 private:
Index: trunk/src/lib/script_engine/script_manager.cc
===================================================================
--- trunk/src/lib/script_engine/script_manager.cc	(revision 9298)
+++ trunk/src/lib/script_engine/script_manager.cc	(revision 9869)
@@ -24,11 +24,8 @@
 #include "lunar.h"
 
-#include "class_list.h"
-
 #include "script.h"
 #include "script_trigger.h"
 #include "luaincl.h"
-#include "loading/load_param.h"
-#include "parser/tinyxml/tinyxml.h"
+#include "loading/load_param_xml.h"
 
 
@@ -37,6 +34,4 @@
 {
   this->setName("ScriptManager");
-  this->scripts = NULL;
-  this->triggers = NULL;
 
   if (root != NULL)
@@ -62,6 +57,4 @@
 
   // fill the scripts and triggers (doing that on runtime is very slow!)
-  getTriggers();
-  getScripts();
 }
 
@@ -71,12 +64,10 @@
 {
   //Delete all scripts as they aren't deleted automatically
-  if(this->getScripts())
-    while(!scripts->empty())
-      delete scripts->front();
+  while(!Script::objectList().empty())
+    delete Script::objectList().front();
   //Delete all triggers
-  if(this->getTriggers())
-    while(!triggers->empty())
-      delete triggers->front();
-  
+  while(!ScriptTrigger::objectList().empty())
+    delete ScriptTrigger::objectList().front();
+
 }
 
@@ -105,28 +96,11 @@
 Script* ScriptManager::getScriptByFile(const std::string& file)
 {
-  if(getScripts())
-    for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ )
-    {
-      if( (dynamic_cast<Script*>(*it))->getFileName().compare(file) == 0)
-      {
-        return dynamic_cast<Script*>(*it);
-      }
-    }
+  for (ObjectList<Script>::const_iterator it = Script::objectList().begin();
+       it != Script::objectList().end();
+       ++it)
+    if( ((*it))->getFileName().compare(file) == 0)
+      return (*it);
 
   return NULL;
 
 }
-
-
-bool ScriptManager::getScripts()
-{
-  return (this->scripts != NULL || (this->scripts = ClassList::getList(CL_SCRIPT)) != NULL);
-}
-
-bool ScriptManager::getTriggers()
-{
-  return (this->triggers != NULL || (this->triggers = ClassList::getList(CL_SCRIPT_TRIGGER)) != NULL);
-}
-
-
-
Index: trunk/src/lib/script_engine/script_manager.h
===================================================================
--- trunk/src/lib/script_engine/script_manager.h	(revision 9298)
+++ trunk/src/lib/script_engine/script_manager.h	(revision 9869)
@@ -34,14 +34,5 @@
    void  createTriggers(const TiXmlElement* triggers);
 
-   bool getTriggers();
-   bool getScripts();
-
    static ScriptManager*             singletonRef;   //!< Reference to this class
-
-   const std::list<BaseObject*>*     triggers;       //!< A list of all the triggers in the world
-
-   const std::list<BaseObject*>*     scripts;        //!< A list of all the scripts in the world
-
-
 };
 #endif
Index: trunk/src/lib/script_engine/script_method.cc
===================================================================
--- trunk/src/lib/script_engine/script_method.cc	(revision 9298)
+++ trunk/src/lib/script_engine/script_method.cc	(revision 9869)
@@ -25,5 +25,5 @@
 { }
 
-ScriptMethod* ScriptMethod::addMethod(const std::string& methodName, const Executor& executor)
+ScriptMethod* ScriptMethod::addMethod(const std::string& methodName, const Executor<lua_State*>& executor)
 {
   this->methods.push_back(ScriptMethod::Method(methodName, executor));
@@ -32,5 +32,5 @@
 }
 
-ScriptMethod::Method::Method(const std::string& name, const Executor& executor)
+ScriptMethod::Method::Method(const std::string& name, const Executor<lua_State*>& executor)
 {
   this->name = name;
Index: trunk/src/lib/script_engine/script_method.h
===================================================================
--- trunk/src/lib/script_engine/script_method.h	(revision 9298)
+++ trunk/src/lib/script_engine/script_method.h	(revision 9869)
@@ -9,6 +9,6 @@
 #include <vector>
 
-#include "executor/executor_lua.h"
-
+#include "executor_lua_state.h"
+#include "executor/executor_member.h"
 
 class ScriptMethod
@@ -18,10 +18,10 @@
   ~ScriptMethod();
 
-  ScriptMethod* addMethod(const std::string& methodName, const Executor& executor);
+  ScriptMethod* addMethod(const std::string& methodName, const Executor<lua_State*>& executor);
 
   unsigned int size() const { return methods.size(); };
 
   const std::string& name(unsigned int methodNumber) const { return methods[methodNumber].name; };
-  const Executor* executor(unsigned int methodNumber) const { return methods[methodNumber].executor; };
+  const Executor<lua_State*>* executor(unsigned int methodNumber) const { return methods[methodNumber].executor; };
 
 
@@ -29,7 +29,7 @@
   struct Method
   {
-    Method(const std::string& name, const Executor& executor);
-    std::string    name;
-    Executor*      executor;
+    Method(const std::string& name, const Executor<lua_State*>& executor);
+    std::string             name;
+    Executor<lua_State*>*   executor;
   };
 
