Changeset 9195 in orxonox.OLD for branches/presentation/src/lib/script_engine
- Timestamp:
- Jul 5, 2006, 9:29:01 AM (18 years ago)
- Location:
- branches/presentation/src/lib/script_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/lib/script_engine/script.cc
r9193 r9195 26 26 CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT, 27 27 addMethod("addObject", ExecutorLua2<Script,const std::string&, const std::string& >(&Script::addObject)) 28 ->addMethod("registerClass", ExecutorLua1<Script,const std::string&>(&Script::registerClass)) 28 29 ->addMethod("selectFunction", ExecutorLua2ret<Script, bool, const std::string&, int >(&Script::selectFunction)) 29 30 ->addMethod("executeFunction", ExecutorLua0ret<Script,bool >(&Script::executeFunction)) … … 78 79 bool Script::loadFile(const std::string& filename) 79 80 { 80 this->setName(filename);81 81 std::string filedest(ResourceManager::getInstance()->getDataDir()); 82 82 filedest += "scripts/" + filename; … … 95 95 if(error == 0) 96 96 { 97 97 currentFile = filename; 98 98 error = lua_pcall(luaState, 0, 0, 0); 99 99 100 100 if(error == 0) 101 101 { 102 currentFile = filename;103 102 return true; 104 103 } … … 360 359 //this->registerClass(std::string("Vector")); 361 360 this->registerClass("ScriptTrigger"); 362 this->registerClass("AttractorMine");361 // this->registerClass("AttractorMine"); 363 362 364 363 return success; … … 366 365 367 366 368 boolScript::registerClass( const std::string& className)367 void Script::registerClass( const std::string& className) 369 368 { 370 369 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS); … … 379 378 tmpObj.name = ""; 380 379 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 { 381 392 return true; 382 393 } 383 394 } 384 395 return false; 385 386 } 387 388 bool Script::classIsRegistered(const std::string& type) 396 } 397 398 399 400 bool Script::objectIsAdded(const std::string& name) 389 401 { 390 402 for(std::list<WorldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ ) 391 403 { 392 if( (*it). type == type)404 if( (*it).name == name) 393 405 { 394 406 return true; … … 396 408 } 397 409 return false; 398 } 399 400 401 402 bool Script::objectIsAdded(const std::string& name) 403 { 404 for(std::list<WorldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ ) 405 { 406 if( (*it).name == name) 407 { 408 return true; 409 } 410 } 411 return false; 412 413 414 } 410 411 412 } -
branches/presentation/src/lib/script_engine/script.h
r9061 r9195 32 32 bool loadFile(const std::string& filename); 33 33 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 34 35 35 36 /// QUERRYING … … 64 65 int reportError(int error); //!< Get errormessage from the lua stack and print it. 65 66 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 instances67 67 bool classIsRegistered(const std::string& type); //!< Checks wheter the class "type" has already been registered with the script 68 68 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.