Changeset 8711 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jun 22, 2006, 1:09:20 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/script_trigger.cc
r8408 r8711 1 //for testing 2 #include "luaincl.h" 1 /* 2 orxonox - the future of 3D-vertical-scrollers 3 4 Copyright (C) 2004 orx 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 ### File Specific: 12 main-programmer: Silvan Nellen 13 co-programmer: ... 14 */ 15 3 16 4 17 #include "script_trigger.h" … … 20 33 this->toList(OM_COMMON); 21 34 35 returnCount = 1; 36 actionFinished = false; 22 37 doDebugDraw = false; 38 invert = false; 23 39 scriptCalled = false; 24 40 scriptIsOk = false; 41 triggerLasts = false; 25 42 loadParams(root); 26 43 … … 71 88 .describe("True if the script shoul only be called once") 72 89 .defaultValues(""); 90 LoadParam(root, "invert", this, ScriptTrigger, setInvert) 91 .describe("") 92 .defaultValues(""); 93 LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts) 94 .describe("") 95 .defaultValues(""); 73 96 LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw) 74 97 .describe("True if the script should only be called once") … … 118 141 void ScriptTrigger::tick(float timestep) 119 142 { 120 121 if( this->distance(target) < radius) 143 if(actionFinished) return; 144 145 if(triggerLasts && scriptCalled) 146 { 147 executeAction(timestep); 148 return; 149 } 150 151 if( !invert && this->distance(target) < radius) 122 152 { 123 153 if(!callOnce) 124 154 { 125 executeAction(); 155 executeAction(timestep); 156 scriptCalled = true; 126 157 } 127 158 else if(callOnce && !scriptCalled) 128 159 { 129 executeAction( );160 executeAction(timestep); 130 161 scriptCalled = true; 131 162 } 163 164 } 165 else if( invert && this->distance(target) > radius) 166 { 167 if(!callOnce) 168 { 169 executeAction(timestep); 170 } 171 else if(callOnce && !scriptCalled) 172 { 173 executeAction(timestep); 174 scriptCalled = true; 175 } 176 132 177 } 133 178 //else … … 137 182 138 183 139 void ScriptTrigger::executeAction( )184 void ScriptTrigger::executeAction(float timestep) 140 185 { 141 186 if(scriptIsOk) 142 187 { 143 testScriptingFramework();144 /*if(!(script->selectFunction(this->functionName,0)) )188 //testScriptingFramework(); 189 if(!(script->selectFunction(this->functionName,returnCount)) ) 145 190 printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str()); 191 192 script->pushParam( timestep, this->functionName); 193 146 194 if( !(script->executeFunction()) ) 147 printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str());*/ 195 printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(), script->getFileName().c_str()); 196 197 actionFinished = script->getReturnedBool(); 148 198 } 199 200 149 201 } 150 202 … … 165 217 } 166 218 167 219 /* 168 220 void ScriptTrigger::testScriptingFramework() 169 221 { … … 208 260 printf("-------------------------- top of the stack:%i\n",lua_gettop(script->getLuaState())); 209 261 210 } 262 }*/ -
trunk/src/world_entities/script_trigger.h
r8408 r8711 1 /*! 2 * @file scrip_trigger.h 3 * triggeres a script 4 */ 5 1 6 #ifndef _SCRIPT_TRIGGER_H 2 7 #define _SCRIPT_TRIGGER_H … … 22 27 /// DO WORK 23 28 virtual void tick(float timestep); 24 virtual void executeAction( );29 virtual void executeAction(float timestep); 25 30 void testScriptingFramework(); 26 31 … … 30 35 void setTriggerParent(const std::string& name); 31 36 void setCallOnce(const bool call) { this->callOnce = call; } 37 void setTriggerLasts(const bool lasts) { this->triggerLasts = lasts; } 38 void setInvert(const bool inv) { this->invert = invert; } 32 39 void setRadius(const float radius) { if(radius>0) this->radius = radius; } 33 40 void setDelay(const float time){if(delay>0) this->delay = delay; } 34 41 void setScript(const std::string& file); 35 void setFunction(const std::string& function){ this->functionName = function; 42 void setFunction(const std::string& function){ this->functionName = function;} 36 43 void setDebugDraw(const bool draw) { this->doDebugDraw = draw; } 37 44 … … 43 50 WorldEntity* target; 44 51 bool callOnce; 52 bool triggerLasts; 53 bool invert; 45 54 float radius; 46 55 float delay; … … 52 61 bool scriptCalled; 53 62 bool scriptIsOk; 63 bool actionFinished; 64 int returnCount; //TODO: set return count correctly 54 65 55 66 }; -
trunk/src/world_entities/space_ships/helicopter.h
r8408 r8711 12 12 #include "sound_buffer.h" 13 13 #include "sound_source.h" 14 15 #include "script_class.h" 14 16 15 17 class Helicopter : public Playable … … 38 40 virtual void process(const Event &event); 39 41 40 virtual void moveUp(bool move){bUp = move;}; 42 virtual void moveUp(bool move){bAscend = move;}; 43 virtual void moveDown(bool move){bDescend = move;}; 41 44 42 45 … … 80 83 }; 81 84 82 //CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER, 83 // addMethod("moveUp", ExecutorLua1<Object,bool>(&Helicopter::moveUp)) 84 // ); 85 CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER, 86 addMethod("moveUp", ExecutorLua1<Helicopter,bool>(&Helicopter::moveUp)) 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 93 ); 85 94 86 95
Note: See TracChangeset
for help on using the changeset viewer.