Index: /branches/script_engine/src/lib/script_engine/script.h
===================================================================
--- /branches/script_engine/src/lib/script_engine/script.h	(revision 8154)
+++ /branches/script_engine/src/lib/script_engine/script.h	(revision 8155)
@@ -27,9 +27,9 @@
     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.
+    // get returned values the last return value in lua is the first in c. TODO: change order of return
     int   getReturnedInt();
     bool  getReturnedBool();
     float getReturnedFloat();
-    void getReturnedString(std::string& string);
+    void  getReturnedString(std::string& string);
 
 
Index: /branches/script_engine/src/lib/script_engine/script_manager.cc
===================================================================
--- /branches/script_engine/src/lib/script_engine/script_manager.cc	(revision 8154)
+++ /branches/script_engine/src/lib/script_engine/script_manager.cc	(revision 8155)
@@ -4,10 +4,10 @@
 #include "script.h"
 #include "script_manager.h"
+#include "lunar.h"
 
 
-ScriptManager::ScriptManager(std::string& world)
+ScriptManager::ScriptManager()
 {
-  this->init(world);
-
+  this->init();
 }
 
@@ -27,28 +27,23 @@
 }
 
+void ScriptManager::loadParams(const TiXmlElement* root)
+{
+  //BaseObject::loadParams(root);
 
-//!< Fills the worldObject list
+  const TiXmlElement* scripts = root->FirstChildElement("Scripts");
 
-void ScriptManager::init(std::string& world)
-{
+  if( element == NULL)
+  {
+    PRINTF(1)("ScriptManager is missing 'Scripts'\n");
+  }
+  else
+  {
+    createScriptList(scripts);
+  }
 
 
 }
 
-
-
-void ScriptManager::loadParams(const TiXmlElement* root)
-{
-  //BaseObject::loadParams(root);
-
-
-}
-
-
 void ScriptManager::tick(float timestep)
-{
-}
-
-void ScriptManager::changeWorld(std::string& newWorld)
 {
 }
@@ -57,5 +52,89 @@
 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("");
+
 }
 
 
+void  ScriptManager::createScriptList(TiXmlElement* scripts)
+{
+  const TiXmlElement* script = scripts->FirstChildElement();
+  const TiXmlElement* object;
+
+  PRINTF(4)("Creating scriptlist\n");
+
+  while( script != NULL)
+  {
+    LoadParam(script, "file", this, ScriptManager, setCurrentScriptFile)
+        .describe("the fileName of the script, that should be loaded into this world")
+        .defaultValues("");
+
+    if(!currentScript.name.empty()) // if LoadParam didn't fail... fill the object list with the needed objects
+    {
+    object = script->FirstChildElement("object");
+
+    while(object != NULL)
+    {
+      addObjectToScript(object->Value(), currentScript);
+      object = object->NextSiblingElement("object");
+    }
+
+    scriptList.push_back(currentScript);
+    }
+
+    script = script->NextSiblingElement("Script");
+
+  }
+
+
+}
+
+void  ScriptManager::setCurrentScriptFile(std::string& file)
+ {
+   if( !fileIsInScriptList(file) )
+     currentScript.name = file;
+   else
+     currentScript.name.assign("");
+ }
+
+void  ScriptManager::addObjectToScript(std::string& object, LuaScript& script)
+{
+  if(!objectIsInObjectList(object,script))
+    script.objectList.push_back(object);
+}
+
+
+bool ScriptManager::fileIsInScriptList(std::string& file)
+{
+  for(std::list<LuaScript>::iterator it = scriptList.begin(); it != scriptList.end(); it++ )
+  {
+    if( (*it).name.compare(file) == 0)
+    {
+      return true;
+    }
+  }
+  return false;
+}
+
+
+bool ScriptManager::objectIsInObjectList(std::string& object, const LuaScript& script)
+{
+  for(std::list<std::string>::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 8154)
+++ /branches/script_engine/src/lib/script_engine/script_manager.h	(revision 8155)
@@ -11,9 +11,10 @@
 
 
-//!< Contains the names of all objects in a world and a list of all script files that need the object.
-struct worldObject
+//!< 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> scriptFiles;
+  std::list<std::string> objectList;
+  Script script;
 };
 
@@ -22,15 +23,12 @@
  public:
    ScriptManager();
-   ScriptManager(std::string& world);
    ~ScriptManager();
 
-   inline static ScriptManager* getInstance();
+  inline static ScriptManager* getInstance();
 
-  void loadParams(const TiXmlElement* root);
+  virtual void loadParams(const TiXmlElement* root);
+  void setWorld(std::string& world){currentWorld = world;}
 
   void tick(float timestep);
-
-  void changeWorld(std::string& newWorld);
-
 
   void initScripts(); // initializes all scripts
@@ -38,9 +36,18 @@
  private:
 
-   void  init(std::string& world);
+   void  init();
+   void  createScriptList(TiXmlElement* scripts);
+   void  setCurrentScriptFile(std::string& file);
+   void  addObjectToScript(std::string& object, LuaScript& script);
 
-   static ScriptManager*      singletonRef; //!< Reference to this class
-   std::list<worldObject> objectList; //!< The list of all Objects in a world (read from the *.oxw file of the world)
-   std::string currentWorld;
+   bool fileIsInScriptList(std::string& file);
+   bool objectIsInObjectList(std::string& object,const LuaScript& script);
+
+
+   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
+
 
 
