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 @@
      }
    }
- 
+
  }
 
