Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9235 in orxonox.OLD for trunk/src/lib/script_engine


Ignore:
Timestamp:
Jul 5, 2006, 4:39:02 PM (19 years ago)
Author:
bensch
Message:

merged the presentation back

Location:
trunk/src/lib/script_engine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/script_engine/script.cc

    r9061 r9235  
    2626CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT,
    2727                    addMethod("addObject", ExecutorLua2<Script,const std::string&, const std::string& >(&Script::addObject))
     28                    ->addMethod("registerClass", ExecutorLua1<Script,const std::string&>(&Script::registerClass))
    2829                    ->addMethod("selectFunction", ExecutorLua2ret<Script, bool, const std::string&, int >(&Script::selectFunction))
    2930                    ->addMethod("executeFunction", ExecutorLua0ret<Script,bool >(&Script::executeFunction))
     
    7879bool Script::loadFile(const std::string& filename)
    7980 {
    80    this->setName(filename);
    8181   std::string filedest(ResourceManager::getInstance()->getDataDir());
    8282   filedest += "scripts/" + filename;
     
    9595   if(error == 0)
    9696   {
    97      
     97     currentFile = filename;
    9898     error = lua_pcall(luaState, 0, 0, 0);
    9999
    100100     if(error == 0)
    101101     {
    102       currentFile = filename;
    103102      return true;
    104103     }
     
    358357   bool success = false;
    359358   
    360    //success = this->registerClass(std::string("Vector"));
    361     success = this->registerClass("ScriptTrigger");
     359   //this->registerClass(std::string("Vector"));
     360    this->registerClass("ScriptTrigger");
     361  //  this->registerClass("AttractorMine");
    362362
    363363   return success;
     
    365365 
    366366 
    367  bool Script::registerClass( const std::string& className)
     367 void Script::registerClass( const std::string& className)
    368368 {
    369369   BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
     
    378378       tmpObj.name = "";
    379379       registeredObjects.push_back(tmpObj);
     380       return;
     381     }
     382   }
     383 
     384 }
     385
     386 bool Script::classIsRegistered(const std::string& type)
     387 {
     388   for(std::list<WorldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ )
     389   {
     390     if( (*it).type == type)
     391     {
    380392       return true;
    381393     }
    382394   }
    383395   return false;
    384  
    385  }
    386 
    387  bool Script::classIsRegistered(const std::string& type)
     396 }
     397
     398
     399
     400 bool Script::objectIsAdded(const std::string& name)
    388401 {
    389402   for(std::list<WorldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ )
    390403   {
    391      if( (*it).type == type)
     404     if( (*it).name == name)
    392405     {
    393406       return true;
     
    395408   }
    396409   return false;
    397  }
    398 
    399 
    400 
    401  bool Script::objectIsAdded(const std::string& name)
    402  {
    403    for(std::list<WorldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ )
    404    {
    405      if( (*it).name == name)
    406      {
    407        return true;
    408      }
    409    }
    410    return false;
    411 
    412 
    413  }
     410
     411
     412 }
  • trunk/src/lib/script_engine/script.h

    r9061 r9235  
    3232    bool loadFile(const std::string& filename);
    3333    void addObject( const std::string& className,const std::string& objectName);
     34    void registerClass(const std::string& className);                           //!< Register a class but dont add any instances
    3435
    3536    /// QUERRYING
     
    6465    int  reportError(int error);                      //!< Get errormessage from the lua stack and print it.
    6566    bool registerStandartClasses();                   //!< Register all the classes that the script might need
    66     bool registerClass(const std::string& className); //!< Register a class but dont add any instances
    6767    bool classIsRegistered(const std::string& type);  //!< Checks wheter the class "type" has already been registered with the script
    6868    bool objectIsAdded(const std::string& name);      //!< Checks wheter the object "name" has already been added to the script
Note: See TracChangeset for help on using the changeset viewer.