Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 2, 2006, 1:36:13 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the single_player_map branche back
merged with command:
svn merge -r8896:HEAD https://svn.orxonox.net/orxonox/branches/single_player_map .
no conflicts

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

Legend:

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

    r8783 r9003  
    2424
    2525#include "class_list.h"
     26// uncommet this when the std:string and the const bug is fixed
     27//CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT,
     28//                               addMethod("addObject", ExecutorLua2<Script,std::string,std::string>(&Script::addObject))
     29//                               ):
    2630
    2731Script::Script(const TiXmlElement* root)
     
    7377bool Script::loadFile(const std::string& filename)
    7478 {
    75 
     79   this->setName(filename);
    7680   std::string filedest(ResourceManager::getInstance()->getDataDir());
    7781   filedest += "scripts/" + filename;
     
    9397     {
    9498      currentFile = filename;
     99      //this->addThisScript();
    95100      return true;
    96101     }
     
    323328 }
    324329
     330
     331void Script::addThisScript()
     332{
     333  BaseObject* scriptClass = ClassList::getObject("Script", CL_SCRIPT_CLASS);
     334   if (scriptClass != NULL)
     335   {
     336     static_cast<ScriptClass*>(scriptClass)->registerClass(this);
     337     static_cast<ScriptClass*>(scriptClass)->insertObject(this, this,"thisscript", false);
     338   }
     339}
     340
    325341 int Script::reportError(int error)
    326342 {
  • trunk/src/lib/script_engine/script.h

    r8711 r9003  
    3131    void loadFileNoRet(const std::string& filename) { loadFile(filename); };
    3232    bool loadFile(const std::string& filename);
    33     void addObject(const std::string& className, const std::string& objectName);
     33    void addObject( const std::string& className,const std::string& objectName);
    3434
    3535    /// QUERRYING
     
    6161
    6262  private:
    63 
     63    void addThisScript();
    6464    int  reportError(int error);                      //!< Get errormessage from the lua stack and print it.
    6565    bool registerStandartClasses();                   //!< Register all the classes that the script might need
  • trunk/src/lib/script_engine/script_class.h

    r8408 r9003  
    3434  virtual void registerClass(Script* script) = 0;
    3535  virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) = 0;
     36  virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0;
    3637
    3738  const ScriptMethod* scriptMethods() const { return this->_scriptMethods; }
     
    6465    return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);
    6566  }
     67
     68  virtual int insertObject(Script* L, BaseObject* obj,const std::string& name, bool gc=false)
     69  {
     70    return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), name, gc);
     71  }
    6672};
    6773
  • trunk/src/lib/script_engine/script_manager.cc

    r8711 r9003  
    7474    while(!scripts->empty())
    7575      delete scripts->front();
     76  //Delete all triggers
     77  if(this->getTriggers())
     78    while(!triggers->empty())
     79      delete triggers->front();
     80 
    7681}
    7782
Note: See TracChangeset for help on using the changeset viewer.