Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10324 in orxonox.OLD for branches


Ignore:
Timestamp:
Jan 24, 2007, 11:26:37 AM (18 years ago)
Author:
snellen
Message:

added addObjectAsName

Location:
branches/scriptchanges/src/lib/script_engine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/scriptchanges/src/lib/script_engine/script.cc

    r10321 r10324  
    170170 }
    171171
     172
     173void Script::addObjectAsName( const std::string& className, const std::string& objectName, const std::string& nameInScript)
     174 {
     175   ScriptClass* scriptClass = ScriptClass::objectList().getObject(className);
     176   WorldObject tmpObj;
     177   if (scriptClass != NULL)
     178   {
     179     tmpObj.type = className;
     180     if( !classIsRegistered(className) )
     181     {
     182       scriptClass->registerClass(this);
     183     }
     184     BaseObject* object = ObjectListBase::getBaseObject(className, objectName);
     185     if (object != NULL && !objectIsAdded(objectName))
     186     {
     187        scriptClass->insertObject(this, object,nameInScript, false);
     188        tmpObj.name = objectName;
     189        registeredObjects.push_back(tmpObj);
     190     }
     191   }
     192 }
    172193
    173194
  • branches/scriptchanges/src/lib/script_engine/script.h

    r9869 r10324  
    3434    bool loadFile(const std::string& filename);
    3535    void addObject( const std::string& className,const std::string& objectName);
     36    void addObjectAsName( const std::string& className,const std::string& objectName, const std::string& nameInScript);
    3637    void registerClass(const std::string& className);                           //!< Register a class but dont add any instances
    3738
  • branches/scriptchanges/src/lib/script_engine/script_class.cc

    r9916 r10324  
    2525CREATE_SCRIPTABLE_CLASS(Script,
    2626                    addMethod("addObject", Executor2<Script, lua_State*,const std::string&, const std::string& >(&Script::addObject))
     27                    ->addMethod("addObjectAsName", Executor3<Script, lua_State*,const std::string&, const std::string&, const std::string& >(&Script::addObjectAsName))
    2728                    ->addMethod("registerClass", Executor1<Script, lua_State*,const std::string&>(&Script::registerClass))
    2829                    ->addMethod("selectFunction", Executor2ret<Script, lua_State*, bool, const std::string&, int >(&Script::selectFunction))
Note: See TracChangeset for help on using the changeset viewer.