Changeset 10609 in orxonox.OLD for branches/scriptimprovements/src/world_entities/script_triggers
- Timestamp:
- Mar 29, 2007, 6:08:23 PM (18 years ago)
- Location:
- branches/scriptimprovements/src/world_entities/script_triggers
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/scriptimprovements/src/world_entities/script_triggers/script_trigger.cc
r10607 r10609 61 61 executionStopped = false; // true when something goes wrong and the trigger has to be stopped 62 62 addToScript = false; 63 this->activeOnCreation = false;64 63 65 64 … … 106 105 .describe("where this script trigger should be located") 107 106 .defaultValues(""); 108 LoadParam(root, "delay", this, ScriptTrigger, setDelay)109 .describe("the delay after which the funtion sould be triggered")110 .defaultValues(0);111 107 LoadParam(root, "triggerparent", this, ScriptTrigger, setTriggerParent) 112 108 .describe("The name of the parent as it is in the *.oxw file") -
branches/scriptimprovements/src/world_entities/script_triggers/script_trigger.h
r10608 r10609 33 33 34 34 /// SET MEMBER 35 36 void setActiveOnCreation(const bool avtive) { this->activeOnCreation = avtive; }37 void setDelay(float delay) { this->delay = delay; };38 35 void setScript(const std::string& file); 39 36 void setFunction(const std::string& function){ this->functionName = function;} … … 41 38 void setAddToScript(const bool add) { this->addToScript = add; } 42 39 void setTriggerParent(const std::string& name); 43 44 inline void setScriptIsOk(bool ok){ scriptIsOk = ok ; }45 inline void setScriptCalled(bool called){ scriptCalled = called; }46 inline void setScriptFinished(bool finished){ scriptFinished = finished; }47 48 ///POLLING49 50 inline bool getScriptIsOk(){ return scriptIsOk; }51 inline bool getScriptCalled(){ return scriptCalled; }52 inline bool getScriptFinished(){ return scriptFinished; }53 40 54 41 … … 58 45 private: 59 46 60 bool activeOnCreation;61 float delay;62 47 Script* script; 63 48 std::string functionName; … … 66 51 67 52 //for internal use 53 bool executionStopped; // true when something goes wrong and the trigger has to be stopped 54 int returnCount; //TODO: set return count correctly 55 56 protected: 57 68 58 bool scriptCalled; 69 59 bool scriptIsOk; 70 bool executionStopped; // true when something goes wrong and the trigger has to be stopped71 60 bool scriptFinished; 72 int returnCount; //TODO: set return count correctly73 61 74 62 }; -
branches/scriptimprovements/src/world_entities/script_triggers/space_trigger.cc
r10608 r10609 116 116 void SpaceTrigger::tick(float timestep) 117 117 { 118 if( this->getScriptFinished()) return;118 if( scriptFinished ) return; 119 119 120 if(triggerRemains && this->getScriptCalled())120 if(triggerRemains && scriptCalled ) 121 121 { 122 122 executeAction(timestep); … … 130 130 //printf("Distance is %f \n", this->distance(target)); 131 131 executeAction(timestep); 132 this->setScriptCalled(true);132 scriptCalled = true; 133 133 return; 134 134 … … 137 137 { 138 138 executeAction(timestep); 139 this->setScriptCalled(true);139 scriptCalled = true; 140 140 return; 141 141 } -
branches/scriptimprovements/src/world_entities/script_triggers/tick_trigger.cc
r10607 r10609 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 16 17 #include "tick_trigger.h" 18 #include "debug.h" 19 20 ObjectListDefinition(TickTrigger); 21 22 // CREATE_SCRIPTABLE_CLASS(TickTrigger, 23 // // Coordinates 24 // addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 25 // ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 26 // ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 27 // ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 28 // //Properties 29 // ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName)) 30 // ->addMethod("setTarget", Executor1<TickTrigger, lua_State*, const std::string&>(&TickTrigger::setTarget)) 31 // ->addMethod("setTriggerParent", Executor1<TickTrigger, lua_State*, const std::string&>(&TickTrigger::setTriggerParent)) 32 // ->addMethod("setTriggerRemains", Executor1<TickTrigger, lua_State*, bool>(&TickTrigger::setTriggerRemains)) 33 // ->addMethod("setActiveOnCreation", Executor1<TickTrigger, lua_State*, bool>(&TickTrigger::setActiveOnCreation)) 34 // ->addMethod("setInvert", Executor1<TickTrigger, lua_State*, bool>(&TickTrigger::setInvert)) 35 // ->addMethod("setRadius", Executor1<TickTrigger, lua_State*, float>(&TickTrigger::setRadius)) 36 // ->addMethod("setScript", Executor1<TickTrigger, lua_State*, const std::string&>(&TickTrigger::setScript)) 37 // ->addMethod("setFunction", Executor1<TickTrigger, lua_State*, const std::string&>(&TickTrigger::setFunction)) 38 // ->addMethod("setDebugDraw", Executor1<TickTrigger, lua_State*, bool>(&TickTrigger::setDebugDraw)) 39 // ->addMethod("setAddToScript", Executor1<TickTrigger, lua_State*, bool>(&TickTrigger::setAddToScript)) 40 // ); 41 42 43 /** 44 * Constructs a new TickTrigger. 45 * @param root the xml element to load the parameters from. 46 * 47 */ 48 TickTrigger::TickTrigger(const TiXmlElement* root) 49 { 50 this->registerObject(this, TickTrigger::_objectList); 51 this->toList(OM_COMMON); 52 53 } 54 55 /** 56 * Deletes the TickTrigger. 57 * 58 */ 59 TickTrigger::~TickTrigger() 60 { 61 62 } 63 64 65 void TickTrigger::tick(float timestep) 66 { 67 if( scriptFinished ) return; 68 69 this->executeAction(timestep); 70 71 } -
branches/scriptimprovements/src/world_entities/script_triggers/tick_trigger.h
r10607 r10609 1 /*! 2 * @file space_trigger.h 3 * always triggeres a script 4 */ 5 6 #ifndef _TICK_TRIGGER_H 7 #define _TICK_TRIGGER_H 8 9 #include <string> 10 11 #include "script.h" 12 #include "script_class.h" 13 #include "script_trigger.h" 14 15 class TickTrigger : public ScriptTrigger 16 { 17 ObjectListDeclaration(TickTrigger); 18 19 public: 20 TickTrigger(const TiXmlElement* root = NULL); 21 ~TickTrigger(); 22 23 /// DO WORK 24 virtual void tick(float timestep); 25 26 }; 27 28 29 #endif
Note: See TracChangeset
for help on using the changeset viewer.