Changeset 8485 in orxonox.OLD for branches/script_engine/src/world_entities/script_trigger.cc
- Timestamp:
- Jun 15, 2006, 5:33:25 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/world_entities/script_trigger.cc
r8417 r8485 20 20 this->toList(OM_COMMON); 21 21 22 returnCount = 1; 23 actionFinished = false; 22 24 doDebugDraw = false; 25 invert = false; 23 26 scriptCalled = false; 24 27 scriptIsOk = false; 28 triggerLasts = false; 25 29 loadParams(root); 26 30 … … 71 75 .describe("True if the script shoul only be called once") 72 76 .defaultValues(""); 77 LoadParam(root, "invert", this, ScriptTrigger, setInvert) 78 .describe("") 79 .defaultValues(""); 80 LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts) 81 .describe("") 82 .defaultValues(""); 73 83 LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw) 74 84 .describe("True if the script should only be called once") … … 118 128 void ScriptTrigger::tick(float timestep) 119 129 { 120 121 if( this->distance(target) < radius) 130 if(actionFinished) return; 131 132 if(triggerLasts && scriptCalled) 133 { 134 executeAction(timestep); 135 return; 136 } 137 138 139 if( !invert && this->distance(target) < radius) 122 140 { 123 141 if(!callOnce) 124 142 { 125 executeAction(); 143 executeAction(timestep); 144 scriptCalled = true; 126 145 } 127 146 else if(callOnce && !scriptCalled) 128 147 { 129 executeAction( );148 executeAction(timestep); 130 149 scriptCalled = true; 131 150 } 151 152 } 153 else if( invert && this->distance(target) > radius) 154 { 155 if(!callOnce) 156 { 157 executeAction(timestep); 158 } 159 else if(callOnce && !scriptCalled) 160 { 161 executeAction(timestep); 162 scriptCalled = true; 163 } 164 132 165 } 133 166 //else … … 137 170 138 171 139 void ScriptTrigger::executeAction( )172 void ScriptTrigger::executeAction(float timestep) 140 173 { 141 174 if(scriptIsOk) 142 175 { 143 testScriptingFramework();144 if(!(script->selectFunction(this->functionName, 0)) )176 //testScriptingFramework(); 177 if(!(script->selectFunction(this->functionName,returnCount)) ) 145 178 printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str()); 179 180 script->pushParam( timestep, this->functionName); 181 146 182 if( !(script->executeFunction()) ) 147 183 printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str()); 148 184 } 185 186 actionFinished = script->getReturnedBool(); 149 187 } 150 188
Note: See TracChangeset
for help on using the changeset viewer.