Changeset 10620 in orxonox.OLD
- Timestamp:
- Apr 5, 2007, 6:11:02 PM (18 years ago)
- Location:
- branches/scriptimprovements/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/scriptimprovements/src/lib/script_engine/script.cc
r10611 r10620 406 406 bool success = false; 407 407 408 //this->registerClass(std::string("Vector"));409 408 this->registerClass("SpaceTrigger"); 410 409 this->registerClass("TickTrigger"); 411 // this->registerClass("AttractorMine");410 this->registerClass("TimeTrigger"); 412 411 413 412 return success; -
branches/scriptimprovements/src/world_entities/WorldEntities.am
r10616 r10620 104 104 world_entities/script_triggers/space_trigger.cc \ 105 105 world_entities/script_triggers/tick_trigger.cc \ 106 world_entities/script_triggers/time_trigger.cc \ 106 107 \ 107 108 \ … … 238 239 script_triggers/space_trigger.h \ 239 240 script_triggers/tick_trigger.h \ 241 script_triggers/time_trigger.h \ 240 242 \ 241 243 \ -
branches/scriptimprovements/src/world_entities/script_triggers/space_trigger.cc
r10616 r10620 49 49 { 50 50 this->registerObject(this, SpaceTrigger::_objectList); 51 //this->toList(OM_COMMON);52 51 53 52 radius = 10; -
branches/scriptimprovements/src/world_entities/script_triggers/tick_trigger.cc
r10616 r10620 15 15 16 16 #include "util/loading/factory.h" 17 #include "script_class.h" 17 18 #include "tick_trigger.h" 18 19 #include "debug.h" … … 43 44 { 44 45 this->registerObject(this, TickTrigger::_objectList); 45 //this->toList(OM_COMMON);46 46 47 47 if(root != NULL) -
branches/scriptimprovements/src/world_entities/script_triggers/tick_trigger.h
r10609 r10620 1 1 /*! 2 * @file space_trigger.h2 * @file tick_trigger.h 3 3 * always triggeres a script 4 4 */ … … 10 10 11 11 #include "script.h" 12 #include "script_class.h"13 12 #include "script_trigger.h" 14 13 -
branches/scriptimprovements/src/world_entities/script_triggers/time_trigger.cc
r10607 r10620 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 #include "util/loading/factory.h" 17 #include "time_trigger.h" 18 #include "debug.h" 19 #include "script_class.h" 20 21 ObjectListDefinition(TimeTrigger); 22 CREATE_FACTORY(TimeTrigger); 23 24 CREATE_SCRIPTABLE_CLASS(TimeTrigger, 25 // Coordinates 26 addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 27 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 28 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 29 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 30 //Properties 31 ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName)) 32 ->addMethod("setScript", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setScript)) 33 ->addMethod("setFunction", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setFunction)) 34 ->addMethod("setDebugDraw", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setDebugDraw)) 35 ->addMethod("start", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::start)) 36 ->addMethod("stop", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::stop)) 37 ->addMethod("reset", Executor0<TimeTrigger, lua_State*>(&TimeTrigger::reset)) 38 ->addMethod("setDelay", Executor1<TimeTrigger, lua_State*, float>(&TimeTrigger::setDelay)) 39 40 ); 41 42 43 /** 44 * Constructs a new TimeTrigger. 45 * @param root the xml element to load the parameters from. 46 * 47 */ 48 TimeTrigger::TimeTrigger(const TiXmlElement* root) 49 { 50 this->registerObject(this, TimeTrigger::_objectList); 51 52 this->delay = 1; 53 this->currentTime = delay; 54 this->isStopped = true; 55 56 if(root != NULL) 57 { 58 loadParams(root); 59 60 if(addToScript && scriptIsOk) 61 { 62 script->addObject( "TimeTrigger", this->getName()); 63 } 64 65 } 66 67 } 68 69 /** 70 * Deletes the TimeTrigger. 71 * 72 */ 73 TimeTrigger::~TimeTrigger() 74 { 75 76 } 77 78 79 void TimeTrigger::tick(float timestep) 80 { 81 if( scriptFinished ) return; 82 83 if( !isStopped ) 84 { 85 currentTime -= timestep; 86 87 if(currentTime < 0) 88 { 89 this->executeAction(timestep); 90 this->stop(); 91 } 92 93 } 94 95 96 } -
branches/scriptimprovements/src/world_entities/script_triggers/time_trigger.h
r10607 r10620 1 /*! 2 * @file time_trigger.h 3 * triggers a script after a given time 4 */ 5 6 #ifndef _TIME_TRIGGER_H 7 #define _TIME_TRIGGER_H 8 9 #include <string> 10 11 #include "script.h" 12 #include "script_trigger.h" 13 14 class TimeTrigger : public ScriptTrigger 15 { 16 ObjectListDeclaration(TimeTrigger); 17 18 public: 19 TimeTrigger(const TiXmlElement* root = NULL); 20 ~TimeTrigger(); 21 22 void setDelay(float newDelay){this->currentTime = this->delay = newDelay;} 23 void start(){ this->isStopped = false; } 24 void stop(){ this->isStopped = true; } 25 void reset(){ this->currentTime = delay; } 26 27 /// DO WORK 28 virtual void tick(float timestep); 29 30 private: 31 float delay; 32 float currentTime; 33 bool isStopped; 34 35 }; 36 37 #endif
Note: See TracChangeset
for help on using the changeset viewer.