- Timestamp:
- Jun 7, 2006, 6:23:33 PM (18 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/script.cc
r8206 r8207 93 93 { 94 94 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS); 95 WorldObject tmpObj; 95 96 if (scriptClass != NULL) 96 97 { 97 98 if( !classIsRegistered(className) ) 99 { 98 100 static_cast<ScriptClass*>(scriptClass)->registerClass(this); 101 tmpObj.type = className; 102 } 99 103 100 104 BaseObject* object = ClassList::getObject(objectName, className); … … 102 106 { 103 107 static_cast<ScriptClass*>(scriptClass)->insertObject(this, object, false); 108 tmpObj.name = objectName; 109 registeredObjects.push_back(tmpObj); 104 110 } 105 111 } … … 296 302 bool Script::classIsRegistered(const std::string& type) 297 303 { 298 for(std::list< worldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ )304 for(std::list<WorldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ ) 299 305 { 300 306 if( (*it).type == type) … … 310 316 bool Script::objectIsAdded(const std::string& name) 311 317 { 312 for(std::list< worldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ )318 for(std::list<WorldObject>::const_iterator it = registeredObjects.begin(); it != registeredObjects.end(); it++ ) 313 319 { 314 320 if( (*it).name == name) -
branches/script_engine/src/lib/script_engine/script.h
r8206 r8207 8 8 struct lua_State; 9 9 10 struct worldObject10 struct WorldObject 11 11 { 12 12 std::string name; … … 57 57 58 58 int reportError(int error); //!< Get errormessage from the lua stack and print it. 59 bool classIsRegistered(const std::string& type); 60 bool objectIsAdded(const std::string& name); 59 bool classIsRegistered(const std::string& type); //!< Checks wheter the class "type" has already been registered with the script 60 bool objectIsAdded(const std::string& name); //!< Checks wheter the object "name" has already been added to the script 61 61 62 62 lua_State* luaState; //!< The lua_State that the Script works on … … 66 66 int returnCount; //!< Number of return values of the current function 67 67 68 std::list< worldObject> registeredObjects; //!< The list of all the objects and their type that have been registered with this script68 std::list<WorldObject> registeredObjects; //!< The list of all the objects and their type that have been registered with this script 69 69 70 70 -
branches/script_engine/src/lib/script_engine/script_trigger.cc
r8206 r8207 21 21 void ScriptTrigger::loadParams(const TiXmlElement* root) 22 22 { 23 if(root != NULL) 24 { 23 25 WorldEntity ::loadParams(root); 24 26 … … 46 48 47 49 } 48 timer = delay; 50 timer = delay; 51 } 52 49 53 } 50 54 … … 71 75 { 72 76 this->setParent(dynamic_cast<WorldEntity*>(parentEntity)); 77 this->setParentMode(PNODE_MOVEMENT); 73 78 } 74 79 else … … 103 108 Script* script = scriptManager->getScriptByFile(this->scriptFile); 104 109 if(script != NULL) 110 { 105 111 if(!(script->selectFunction(this->functionName,0)) ) 106 112 printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), scriptFile.c_str()); 107 113 if( !(script->executeFunction()) ) 108 114 printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(),scriptFile.c_str()); 115 } 109 116 } -
branches/script_engine/src/lib/script_engine/script_trigger.h
r8205 r8207 12 12 { 13 13 public: 14 ScriptTrigger(const TiXmlElement* root );14 ScriptTrigger(const TiXmlElement* root = NULL); 15 15 ~ScriptTrigger(); 16 16 17 ///LOADING 17 18 virtual void loadParams(const TiXmlElement* root); 19 20 21 /// 18 22 virtual void tick(float timestep); 19 23 virtual void executeAction(); … … 30 34 void setScript(const std::string& script){this->scriptFile = script;} 31 35 void setFunction(const std::string& function){this->functionName = function;} 32 33 std::string getTargetName();34 36 35 37 private:
Note: See TracChangeset
for help on using the changeset viewer.