Changeset 8894 in orxonox.OLD for trunk/src/world_entities/script_trigger.cc
- Timestamp:
- Jun 29, 2006, 12:19:48 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/script_trigger.cc
r8783 r8894 24 24 CREATE_SCRIPTABLE_CLASS(ScriptTrigger, CL_SCRIPT_TRIGGER, 25 25 addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 26 27 28 26 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) 27 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 28 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 29 29 ); 30 30 … … 41 41 42 42 returnCount = 1; 43 actionFinished = false;43 scriptFinished = false; 44 44 doDebugDraw = false; 45 45 invert = false; 46 46 scriptCalled = false; 47 47 scriptIsOk = false; 48 triggerLasts = false;48 triggerLasts = true; 49 49 addToScript = false; 50 50 … … 54 54 loadParams(root); 55 55 56 if(addToScript )56 if(addToScript && scriptIsOk) 57 57 { 58 58 script->addObject( "ScriptTrigger", this->getName()); … … 102 102 .describe("The name of the parent as it is in the *.oxw file") 103 103 .defaultValues(""); 104 LoadParam(root, "callonce", this, ScriptTrigger, setCallOnce)105 .describe("True if the script shoul only be called once")106 .defaultValues("");107 104 LoadParam(root, "invert", this, ScriptTrigger, setInvert) 108 105 .describe("") 109 .defaultValues(" ");106 .defaultValues("false"); 110 107 LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts) 111 108 .describe("") 112 .defaultValues(" ");109 .defaultValues("true"); 113 110 LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw) 114 .describe(" True if the script should only be called once")115 .defaultValues(" ");111 .describe("") 112 .defaultValues("false"); 116 113 LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript) 117 114 .describe("True if this scripttrigger should be aviable in the script") 118 .defaultValues(" ");115 .defaultValues("false"); 119 116 } 120 117 … … 159 156 void ScriptTrigger::tick(float timestep) 160 157 { 161 if( actionFinished) return;158 if(scriptFinished) return; 162 159 163 160 if(triggerLasts && scriptCalled) … … 169 166 if( !invert && this->distance(target) < radius) 170 167 { 171 if(!callOnce)172 {173 168 executeAction(timestep); 174 169 scriptCalled = true; 175 }176 else if(callOnce && !scriptCalled)177 {178 executeAction(timestep);179 scriptCalled = true;180 }181 170 182 171 } 183 172 else if( invert && this->distance(target) > radius) 184 173 { 185 if(!callOnce) 186 { 187 executeAction(timestep); 188 } 189 else if(callOnce && !scriptCalled) 190 { 191 executeAction(timestep); 174 executeAction(timestep); 192 175 scriptCalled = true; 193 }194 195 176 } 196 177 //else … … 202 183 void ScriptTrigger::executeAction(float timestep) 203 184 { 185 204 186 if(scriptIsOk) 205 187 { … … 213 195 printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str()); 214 196 215 actionFinished = script->getReturnedBool();197 scriptFinished = script->getReturnedBool(); 216 198 } 217 199
Note: See TracChangeset
for help on using the changeset viewer.