Changeset 8485 in orxonox.OLD for branches/script_engine/src/world_entities
- Timestamp:
- Jun 15, 2006, 5:33:25 PM (18 years ago)
- Location:
- branches/script_engine/src/world_entities
- Files:
-
- 3 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 -
branches/script_engine/src/world_entities/script_trigger.h
r8408 r8485 22 22 /// DO WORK 23 23 virtual void tick(float timestep); 24 virtual void executeAction( );24 virtual void executeAction(float timestep); 25 25 void testScriptingFramework(); 26 26 … … 30 30 void setTriggerParent(const std::string& name); 31 31 void setCallOnce(const bool call) { this->callOnce = call; } 32 void setTriggerLasts(const bool lasts) { this->triggerLasts = lasts; } 33 void setInvert(const bool inv) { this->invert = invert; } 32 34 void setRadius(const float radius) { if(radius>0) this->radius = radius; } 33 35 void setDelay(const float time){if(delay>0) this->delay = delay; } 34 36 void setScript(const std::string& file); 35 void setFunction(const std::string& function){ this->functionName = function; 37 void setFunction(const std::string& function){ this->functionName = function;} 36 38 void setDebugDraw(const bool draw) { this->doDebugDraw = draw; } 37 39 … … 43 45 WorldEntity* target; 44 46 bool callOnce; 47 bool triggerLasts; 48 bool invert; 45 49 float radius; 46 50 float delay; … … 52 56 bool scriptCalled; 53 57 bool scriptIsOk; 58 bool actionFinished; 59 int returnCount; 54 60 55 61 }; -
branches/script_engine/src/world_entities/space_ships/helicopter.h
r8417 r8485 86 86 addMethod("moveUp", ExecutorLua1<Helicopter,bool>(&Helicopter::moveUp)) 87 87 ->addMethod("moveDown", ExecutorLua1<Helicopter,bool>(&Helicopter::moveDown)) 88 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 89 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) 90 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 91 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 92 88 93 ); 89 94
Note: See TracChangeset
for help on using the changeset viewer.