Changeset 8211 in orxonox.OLD for branches/script_engine/src
- Timestamp:
- Jun 7, 2006, 8:47:05 PM (18 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/script_manager.cc
r8210 r8211 38 38 //BaseObject::loadParams(root); 39 39 { 40 LoadParamXML(root, "Scripts", this, ScriptManager, createScripts); 41 40 42 LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers); 41 42 LoadParamXML(root, "Scripts", this, ScriptManager, createScripts);43 43 } // make shure that the loading process is finished 44 44 … … 55 55 if(getScripts()) 56 56 for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ ) 57 {58 ClassList::removeFromClassList( (*it) );59 }57 { 58 ClassList::removeFromClassList( (*it) ); 59 } 60 60 61 61 this->scripts = NULL; -
branches/script_engine/src/lib/script_engine/script_trigger.cc
r8208 r8211 7 7 { 8 8 scriptCalled = false; 9 callScript = false; 10 triggered = false; 9 scriptIsOk = false; 11 10 loadParams(root); 12 11 … … 24 23 { 25 24 WorldEntity ::loadParams(root); 26 25 27 26 { LoadParam(root, "file", this, ScriptTrigger, setScript) 28 27 .describe("the fileName of the script, that should be triggered by this script trigger") … … 50 49 timer = delay; 51 50 } 52 51 53 52 } 54 53 … … 57 56 { 58 57 BaseObject* targetEntity = ClassList::getObject(target, CL_WORLD_ENTITY); 59 58 60 59 if (targetEntity != NULL) 61 60 { … … 71 70 { 72 71 BaseObject* parentEntity = ClassList::getObject(parent, CL_WORLD_ENTITY); 73 72 74 73 if (parentEntity != NULL) 75 74 { … … 105 104 void ScriptTrigger::executeAction() 106 105 { 107 ScriptManager* scriptManager = ScriptManager::getInstance(); 108 Script* script = scriptManager->getScriptByFile(this->scriptFile); 109 if(script != NULL) 106 if(scriptIsOk) 110 107 { 111 108 if(!(script->selectFunction(this->functionName,0)) ) … … 115 112 } 116 113 } 114 115 116 void ScriptTrigger::setScript(const std::string& file) 117 { 118 ScriptManager* scriptManager = ScriptManager::getInstance(); 119 script = scriptManager->getScriptByFile(file); 120 if(script != NULL) 121 scriptIsOk = true; 122 123 } -
branches/script_engine/src/lib/script_engine/script_trigger.h
r8208 r8211 8 8 #include "vector.h" 9 9 #include "script_manager.h" 10 #include "script.h" 10 11 11 12 class ScriptTrigger : public WorldEntity … … 17 18 ///LOADING 18 19 virtual void loadParams(const TiXmlElement* root); 19 20 20 21 21 22 /// DO WORK 22 23 virtual void tick(float timestep); … … 30 31 void setRadius(const float radius) { if(radius>0) this->radius = radius; } 31 32 void setDelay(const float time){if(delay>0) this->delay = delay; } 32 void setScript(const std::string& script){ this->scriptFile = script; }33 void setScript(const std::string& file); 33 34 void setFunction(const std::string& function){ this->functionName = function; } 34 35 … … 40 41 float radius; 41 42 float delay; 42 std::string scriptFile;43 Script* script; 43 44 std::string functionName; 44 45 45 46 //for internal use 46 47 bool scriptCalled; 47 bool callScript; 48 bool triggered; 49 float timer; 48 bool scriptIsOk; 50 49 51 50 };
Note: See TracChangeset
for help on using the changeset viewer.