Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10609 in orxonox.OLD


Ignore:
Timestamp:
Mar 29, 2007, 6:08:23 PM (17 years ago)
Author:
snellen
Message:

added tick trigger which always calles the script

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  
    6161  executionStopped = false; // true when something goes wrong and the trigger has to be stopped
    6262  addToScript = false;
    63   this->activeOnCreation = false;
    6463
    6564
     
    106105      .describe("where this script trigger should be located")
    107106      .defaultValues("");
    108   LoadParam(root, "delay", this, ScriptTrigger, setDelay)
    109       .describe("the delay after which the funtion sould be triggered")
    110       .defaultValues(0);
    111107  LoadParam(root, "triggerparent", this, ScriptTrigger, setTriggerParent)
    112108      .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  
    3333
    3434    /// SET MEMBER
    35  
    36     void setActiveOnCreation(const bool avtive) { this->activeOnCreation = avtive; }
    37     void setDelay(float delay) { this->delay = delay; };
    3835    void setScript(const std::string& file);
    3936    void setFunction(const std::string& function){ this->functionName = function;}
     
    4138    void setAddToScript(const bool add) { this->addToScript = add; }
    4239    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     ///POLLING
    49 
    50     inline bool getScriptIsOk(){ return scriptIsOk; }
    51     inline bool getScriptCalled(){ return scriptCalled; }
    52     inline bool getScriptFinished(){ return scriptFinished; }
    5340   
    5441   
     
    5845  private:
    5946
    60     bool         activeOnCreation;
    61     float        delay;
    6247    Script*      script;
    6348    std::string  functionName;
     
    6651   
    6752    //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   
    6858    bool         scriptCalled;
    6959    bool         scriptIsOk;
    70     bool         executionStopped;   // true when something goes wrong and the trigger has to be stopped
    7160    bool         scriptFinished;
    72     int          returnCount;        //TODO: set return count correctly
    7361
    7462};
  • branches/scriptimprovements/src/world_entities/script_triggers/space_trigger.cc

    r10608 r10609  
    116116void SpaceTrigger::tick(float timestep)
    117117{
    118   if( this->getScriptFinished() ) return;
     118  if( scriptFinished ) return;
    119119
    120   if(triggerRemains && this->getScriptCalled() )
     120  if(triggerRemains && scriptCalled )
    121121  {
    122122    executeAction(timestep);
     
    130130    //printf("Distance is %f \n", this->distance(target));
    131131      executeAction(timestep);
    132       this->setScriptCalled(true);
     132      scriptCalled = true;
    133133      return;
    134134
     
    137137    {
    138138      executeAction(timestep);
    139       this->setScriptCalled(true);
     139      scriptCalled = true;
    140140      return;
    141141    }
  • 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
     20ObjectListDefinition(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 */
     48TickTrigger::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 */
     59TickTrigger::~TickTrigger()
     60{
     61
     62}
     63
     64
     65void 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
     15class 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.