Index: /branches/script_engine/src/defs/class_id.h
===================================================================
--- /branches/script_engine/src/defs/class_id.h	(revision 8192)
+++ /branches/script_engine/src/defs/class_id.h	(revision 8193)
@@ -83,6 +83,4 @@
 
   CL_WORLD_ENTITY               =    0x40000000,
-
-  CL_RESOURCE                   =    0x80000000,
 
   /// subsuper-classes
@@ -238,4 +236,10 @@
   CL_AMMO_CONTAINER             =    0x00000604,
   CL_HUD                        =    0x00000620,
+  
+  
+  CL_SCRIPT_MANAGER             =    0x00000650,
+  CL_SCRIPT                     =    0x00000651,
+  CL_SCRIPTABLE                 =    0x00000652,
+  CL_SCRIPT_TRIGGER             =    0x00000652,
 
 
Index: /branches/script_engine/src/lib/script_engine/Makefile.am
===================================================================
--- /branches/script_engine/src/lib/script_engine/Makefile.am	(revision 8192)
+++ /branches/script_engine/src/lib/script_engine/Makefile.am	(revision 8193)
@@ -15,4 +15,5 @@
                 script.cc\
                 script_manager.cc\
+		scriptable.cc \
                 script_trigger.cc
 
@@ -23,4 +24,5 @@
                 script.h\
                 script_manager.h\
+		scriptable.h \
                 script_trigger.h
 
Index: /branches/script_engine/src/lib/script_engine/lunar.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/lunar.h	(revision 8192)
+++ /branches/script_engine/src/lib/script_engine/lunar.h	(revision 8193)
@@ -3,4 +3,5 @@
 
 #include <string>
+#include <cassert>
 #include "script.h"
 
@@ -140,8 +141,6 @@
       static int insertObject(Script* script, T* obj, const std::string& name, bool gc=false)
       {
-        if(script != NULL)
-          return insertObject(script->getLuaState(), obj, name, gc);
-
-
+        assert (script != NULL);
+        return insertObject(script->getLuaState(), obj, name, gc);
       }
 
Index: /branches/script_engine/src/lib/script_engine/script.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/script.cc	(revision 8192)
+++ /branches/script_engine/src/lib/script_engine/script.cc	(revision 8193)
@@ -1,7 +1,10 @@
 #include "script.h"
-
-
-Script::Script()
+#include "loading/load_param.h"
+
+
+Script::Script(const TiXmlElement* root)
 {
+  this->setClassID(CL_SCRIPT, "Script");
+  
   returnCount = argumentCount = 0;
 
@@ -14,4 +17,7 @@
   luaopen_math(luaState);
   luaopen_debug(luaState);
+  
+  if (root != NULL)
+    this->loadParams(root);
 
 }
@@ -25,5 +31,22 @@
 
 
-bool Script::loadFile(std::string& filename)
+void Script::loadParams(const TiXmlElement* root)
+{
+  LOAD_PARAM_START_CYCLE(root, objectElement);
+  {
+    LoadParam_CYCLE(objectElement, "object", this, Script, addObject)
+        .describe("The name of an object that is needed by a script");
+  }
+  LOAD_PARAM_END_CYCLE(objectElement);
+
+
+  LoadParam(root, "file", this, Script, loadFileNoRet)
+      .describe("the fileName of the script, that should be loaded into this world")
+      .defaultValues("");
+}
+
+
+
+bool Script::loadFile(const std::string& filename)
  {
 
@@ -59,4 +82,13 @@
  }
 
+ 
+ void Script::addObject(const std::string& className, const std::string& objectName)
+ {
+   
+ }
+
+ 
+ 
+ 
  bool Script::executeFile()
  {
Index: /branches/script_engine/src/lib/script_engine/script.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/script.h	(revision 8192)
+++ /branches/script_engine/src/lib/script_engine/script.h	(revision 8193)
@@ -3,5 +3,4 @@
 
 
-#include <string>
 #include "base_object.h"
 
@@ -9,23 +8,39 @@
 
 
-class Script
+class Script : public BaseObject
 {
   public:
-    Script();
+    Script(const TiXmlElement* root = NULL);
     ~Script();
+    
+    /// LOADING
+    void loadParams(const TiXmlElement* root);
 
-    bool loadFile(std::string& filename);
-    std::string getFileName(){return currentFile;}
-    bool executeFile();
+    void loadFileNoRet(const std::string& filename) { loadFile(filename); };
+    bool loadFile(const std::string& filename);
+    /** @returns fileName */
+    std::string getFileName() { return currentFile; }
 
-    lua_State* getLuaState() const{return luaState;}
+    void addObject(const std::string& className, const std::string& objectName);
+    
+        
 
+    lua_State* getLuaState() const { return luaState; }
+
+
+    
+    /// EXECUTING
+    // first select function
     bool selectFunction(std::string& functionName, int retCount);
-    bool executeFunction();
+
     // push parameters for luafunction
     bool  pushParam(int param, std::string& toFunction);
     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. TODO: change order of return
+
+    // Execute the Function
+    bool executeFunction();
+    
+     // get returned values the last return value in lua is the first in c. TODO: change order of return
     int   getReturnedInt();
     bool  getReturnedBool();
@@ -33,4 +48,5 @@
     void  getReturnedString(std::string& string);
 
+    bool executeFile();
 
   private:
@@ -46,5 +62,4 @@
 
 
-
 };
 #endif /* _SCRIPT_H */
Index: /branches/script_engine/src/lib/script_engine/script_manager.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/script_manager.cc	(revision 8192)
+++ /branches/script_engine/src/lib/script_engine/script_manager.cc	(revision 8193)
@@ -31,16 +31,6 @@
    }
 
-  const TiXmlElement* scripts = root->FirstChildElement("Scripts");
-
-  if( scripts == NULL)
-  {
-    PRINTF(1)("ScriptManager is missing 'Scripts'\n");
-  }
-  else
-  {
-    createScriptList(scripts);
-  }
-
-
+   
+   LoadParamXML(root, "Scripts", this, ScriptManager, createScriptList);
 }
 
@@ -50,15 +40,6 @@
 
 
-void ScriptManager::initScripts()
-{
-  for(std::list<LuaScript>::iterator it = scriptList.begin(); it != scriptList.end(); it++ )
-  {
-    (*it).script.loadFile((*it).name);
-  }
-}
-
 void ScriptManager::init()
 {
-  currentWorld.assign("");
 
 }
@@ -67,4 +48,13 @@
 void  ScriptManager::createScriptList(const TiXmlElement* scripts)
 {
+  
+  LOAD_PARAM_START_CYCLE(scripts, object);
+  {
+    new Script(object);
+  }
+  LOAD_PARAM_END_CYCLE(object);
+      
+      
+  /*
   const TiXmlElement* script = scripts->FirstChildElement();
 
@@ -94,5 +84,5 @@
     script = script->NextSiblingElement("Script");
 
-  }
+  }*/
 
 
@@ -103,54 +93,13 @@
 {
 
-  for(std::list<LuaScript>::iterator it = scriptList.begin(); it != scriptList.end(); it++ )
-  {
-    if( (*it).name.compare(file) == 0)
-    {
-      return &((*it).script);
-    }
-  }
-  return NULL;
+//   for(std::list<LuaScript>::iterator it = scriptList.begin(); it != scriptList.end(); it++ )
+//   {
+//     if( (*it).name.compare(file) == 0)
+//     {
+//       return &((*it).script);
+//     }
+//   }
+//   return NULL;
 
 }
 
-void  ScriptManager::setCurrentScriptFile(const std::string& file)
- {
-   if( !fileIsInScriptList(file) )
-     currentScript.name = file;
-   else
-     currentScript.name.assign("");
- }
-
-void  ScriptManager::addObjectToScript(const std::string object)
-{
-  if(!objectIsInObjectList(object,currentScript))
-    currentScript.objectList.push_back(object);
-}
-
-
-bool ScriptManager::fileIsInScriptList(const std::string& file)
-{
-  for(std::list<LuaScript>::const_iterator it = scriptList.begin(); it != scriptList.end(); it++ )
-  {
-    if( (*it).name.compare(file) == 0)
-    {
-      return true;
-    }
-  }
-  return false;
-}
-
-
-bool ScriptManager::objectIsInObjectList(const std::string& object, const LuaScript& script)
-{
-  for(std::list<std::string>::const_iterator it = script.objectList.begin(); it != script.objectList.end(); it++ )
-  {
-    if( (*it).compare(object) == 0)
-    {
-      return true;
-    }
-  }
-  return false;
-}
-
-
Index: /branches/script_engine/src/lib/script_engine/script_manager.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/script_manager.h	(revision 8192)
+++ /branches/script_engine/src/lib/script_engine/script_manager.h	(revision 8193)
@@ -6,5 +6,4 @@
 
 #include "script.h"
-#include "script_trigger.h"
 #include "base_object.h"
 #include "luaincl.h"
@@ -12,12 +11,6 @@
 
 
-//!< Contains the name of a lua script file  and a list of all objects that the script needs
-struct LuaScript
-{
-  std::string name;
-  std::list<std::string> objectList;
-  Script script;
-};
-
+class ScriptTrigger;
+class Scriptable;
 
 class ScriptManager : public BaseObject
@@ -27,32 +20,27 @@
    ~ScriptManager();
 
-  inline static ScriptManager* getInstance(){if (!ScriptManager::singletonRef)ScriptManager::singletonRef = new ScriptManager();return ScriptManager::singletonRef;}
+  inline static ScriptManager* getInstance() { if (!ScriptManager::singletonRef)ScriptManager::singletonRef = new ScriptManager(); return ScriptManager::singletonRef; }
 
   virtual void loadParams(const TiXmlElement* root);
-  void setWorld(const std::string& world) {currentWorld = world;}
 
   void tick(float timestep);
 
-  void initScripts(); // initializes all scripts
   Script* getScriptByFile(std::string& file);
 
+
+  
  private:
 
    void  init();
    void  createScriptList(const TiXmlElement* scripts);
-   void  setCurrentScriptFile(const std::string& file);
    void  addObjectToScript(const std::string object);
 
-   bool fileIsInScriptList(const std::string& file);
-   bool objectIsInObjectList(const std::string& object, const LuaScript& script);
 
+   static ScriptManager*             singletonRef;   //!< Reference to this class
 
-   static ScriptManager*      singletonRef;   //!< Reference to this class
-   std::list<LuaScript>       scriptList;     //!< The list of all scripts that the current world needs
-   std::string                currentWorld;
-   LuaScript                  currentScript;  //!< For temorary use
+   const std::list<BaseObject*>*     triggerList;
 
-
-
+   const std::list<BaseObject*>*     scriptableClasses;
+   const std::list<BaseObject*>*     scripts;
 
 
Index: /branches/script_engine/src/lib/script_engine/script_trigger.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/script_trigger.h	(revision 8192)
+++ /branches/script_engine/src/lib/script_engine/script_trigger.h	(revision 8193)
@@ -21,6 +21,6 @@
     void setTarget(WorldEntity* target){ if(target!=NULL) this->target=target;if(worldEntityIsParent)this->setParent(target);}
     void setTargetName(std::string& name){this->targetName = name;}
-    void setCallOnce(bool call){this->callOnce = call;}
-    void setRadius(float radius){if(radius>0) this->radius = radius;}
+    void setCallOnce(bool call) { this->callOnce = call;}
+    void setRadius(float radius) { if(radius>0) this->radius = radius;}
     void setDelay(float time){if(delay>0) this->delay = delay;}
     void setScript(std::string& script){this->scriptFile = script;}
@@ -31,4 +31,5 @@
   private:
 
+    std::string  parentName;
     WorldEntity* target;
     std::string  targetName;
Index: /branches/script_engine/src/lib/script_engine/scriptable.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/scriptable.cc	(revision 8193)
+++ /branches/script_engine/src/lib/script_engine/scriptable.cc	(revision 8193)
@@ -0,0 +1,43 @@
+/*
+   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 "scriptable.h"
+
+using namespace std;
+
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+Scriptable::Scriptable(const std::string& name, ClassID classID)
+ : BaseObject(name)
+{
+   this->setClassID(CL_SCRIPTABLE, "Scriptable");
+   this->classID = classID;
+
+
+}
+
+
+/**
+ * standard deconstructor
+*/
+Scriptable::~Scriptable ()
+{
+  // delete what has to be deleted here
+}
Index: /branches/script_engine/src/lib/script_engine/scriptable.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/scriptable.h	(revision 8193)
+++ /branches/script_engine/src/lib/script_engine/scriptable.h	(revision 8193)
@@ -0,0 +1,69 @@
+/*!
+ * @file scriptable.h
+ * @brief Definition of ...
+*/
+
+#ifndef _SCRIPTABLE_H
+#define _SCRIPTABLE_H
+
+#include "base_object.h"
+
+#include "script.h"
+#include "lunar.h"
+
+// FORWARD DECLARATION
+
+
+/**
+ * Creates a factory to a Loadable Class.
+ * 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) \
+    tScriptable<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_ID)
+
+
+
+//! A class for ...
+class Scriptable : virtual protected BaseObject
+{
+
+public:
+  Scriptable(const std::string& name, ClassID classID);
+  virtual ~Scriptable();
+
+  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, const std::string& name, bool gc=false) = 0;
+
+private:
+  ClassID             classID;
+};
+
+
+
+
+template <class T>
+class tScriptable : public Scriptable
+{
+  tScriptable(const std::string& name, ClassID classID)
+  : Scriptable(name, classID)
+  { }
+
+  virtual void registerClass(Script* script)
+  {
+    Lunar<T>::Register(script);
+  }
+  virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) 
+  {
+    Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), name, gc);
+  }
+  
+
+
+}
+;
+
+
+#endif /* _SCRIPTABLE_H */
Index: /branches/script_engine/src/lib/util/loading/resource.cc
===================================================================
--- /branches/script_engine/src/lib/util/loading/resource.cc	(revision 8192)
+++ /branches/script_engine/src/lib/util/loading/resource.cc	(revision 8193)
@@ -26,5 +26,5 @@
 Resource::Resource (const std::string& fileName)
 {
-   this->setClassID(CL_RESOURCE, "Resource");
+//   this->setClassID(CL_RESOURCE, "Resource");
 
 }
