Changeset 8178 in orxonox.OLD for branches/script_engine
- Timestamp:
- Jun 6, 2006, 8:47:40 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_manager.cc
r8171 r8178 22 22 { 23 23 //BaseObject::loadParams(root); 24 25 const TiXmlElement* scripttrigger= root->FirstChildElement("ScriptTrigger"); 26 27 while( scripttrigger != NULL) 28 { 29 //TODO: generate script trigger in factory and let them load their params. 30 scripttrigger = scripttrigger->NextSiblingElement("ScriptTrigger"); 31 } 24 32 25 33 const TiXmlElement* scripts = root->FirstChildElement("Scripts"); -
branches/script_engine/src/lib/script_engine/script_manager.h
r8171 r8178 6 6 7 7 #include "script.h" 8 #include "script_trigger.h" 8 9 #include "base_object.h" 9 10 #include "luaincl.h" … … 18 19 Script script; 19 20 }; 21 20 22 21 23 class ScriptManager : public BaseObject … … 53 55 54 56 57 58 55 59 }; 56 60 #endif -
branches/script_engine/src/lib/script_engine/script_trigger.cc
r8173 r8178 23 23 .defaultValues(""); 24 24 LoadParam(root, "abs-coor", this, ScriptTrigger, setAbsCoord) 25 .describe(" the fileName of the script, that should be triggered by this script trigger")25 .describe("where this script trigger should be located") 26 26 .defaultValues(""); 27 27 LoadParam(root, "radius", this, ScriptTrigger, setRadius) … … 31 31 .describe("the delay after which the funtion sould be triggered") 32 32 .defaultValues(0); 33 LoadParam(root, "worldentity", this, ScriptTrigger, setTargetName) 34 .describe("The name of the target as it is in the *.oxw file") 35 .defaultValues(""); 36 LoadParam(root, "worldentityisparent", this, ScriptTrigger, setIsParent) 37 .describe("The name of the target as it is in the *.oxw file") 38 .defaultValues(""); 39 33 40 }*/ 34 41 timer = delay; … … 39 46 void ScriptTrigger::tick(float timestep) 40 47 { 41 //if(triggered)42 //{43 //timer -= timestep;44 //if(timer < 0)45 callScript = true;46 //}47 48 48 49 49 if((this->getAbsDirV()-target->getAbsDirV()).len() < radius) 50 50 { 51 //triggered = true; 52 if(!callOnce && callScript) 51 if(!callOnce) 53 52 { 54 53 executeAction(); 55 54 } 56 else if(callOnce && !scriptCalled && callScript)55 else if(callOnce && !scriptCalled) 57 56 { 58 57 executeAction(); … … 70 69 Script* script = scriptManager->getScriptByFile(this->scriptFile); 71 70 if(!(script->selectFunction(this->functionName,0)) ) 72 printf("Error : Selection of %s in %s failed.\n",functionName.c_str(), scriptFile.c_str());71 printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), scriptFile.c_str()); 73 72 if( !(script->executeFunction()) ) 74 printf("E xecution of %s in %s failed\n",functionName.c_str(),scriptFile.c_str());73 printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(),scriptFile.c_str()); 75 74 } -
branches/script_engine/src/lib/script_engine/script_trigger.h
r8173 r8178 19 19 virtual void executeAction(); 20 20 21 void setTarget(WorldEntity* target){ if(target!=NULL) this->target=target;} 21 void setTarget(WorldEntity* target){ if(target!=NULL) this->target=target;if(worldEntityIsParent)this->setParent(target);} 22 void setTargetName(std::string& name){this->targetName = name;} 22 23 void setCallOnce(bool call){this->callOnce = call;} 23 24 void setRadius(float radius){if(radius>0) this->radius = radius;} … … 26 27 void setFunction(std::string& function){this->functionName = function;} 27 28 29 std::string getTargetName(){return targetName;} 30 28 31 private: 29 32 30 33 WorldEntity* target; 31 bool callOnce; 34 std::string targetName; 35 bool worldEntityIsParent; 36 bool callOnce; 32 37 bool scriptCalled; 33 38 float radius;
Note: See TracChangeset
for help on using the changeset viewer.