Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8211 in orxonox.OLD for branches/script_engine/src/lib


Ignore:
Timestamp:
Jun 7, 2006, 8:47:05 PM (19 years ago)
Author:
snellen
Message:

cleaned script trigger, added member: a pointer to the required script

Location:
branches/script_engine/src/lib/script_engine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/script_engine/script_manager.cc

    r8210 r8211  
    3838  //BaseObject::loadParams(root);
    3939  {
     40  LoadParamXML(root, "Scripts", this, ScriptManager, createScripts);
     41
    4042  LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers);
    41 
    42   LoadParamXML(root, "Scripts", this, ScriptManager, createScripts);
    4343  } // make shure that the loading process is finished
    4444
     
    5555  if(getScripts())
    5656    for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ )
    57   {
    58     ClassList::removeFromClassList( (*it) );
    59   }
     57    {
     58     ClassList::removeFromClassList( (*it) );
     59    }
    6060
    6161  this->scripts = NULL;
  • branches/script_engine/src/lib/script_engine/script_trigger.cc

    r8208 r8211  
    77{
    88  scriptCalled = false;
    9   callScript = false;
    10   triggered = false;
     9  scriptIsOk = false;
    1110  loadParams(root);
    1211
     
    2423  {
    2524  WorldEntity ::loadParams(root);
    26  
     25
    2726   { LoadParam(root, "file", this, ScriptTrigger, setScript)
    2827        .describe("the fileName of the script, that should be triggered by this script trigger")
     
    5049    timer = delay;
    5150  }
    52  
     51
    5352}
    5453
     
    5756{
    5857  BaseObject* targetEntity = ClassList::getObject(target, CL_WORLD_ENTITY);
    59  
     58
    6059  if (targetEntity != NULL)
    6160  {
     
    7170{
    7271  BaseObject* parentEntity = ClassList::getObject(parent, CL_WORLD_ENTITY);
    73  
     72
    7473  if (parentEntity != NULL)
    7574  {
     
    105104void ScriptTrigger::executeAction()
    106105{
    107      ScriptManager* scriptManager = ScriptManager::getInstance();
    108      Script* script = scriptManager->getScriptByFile(this->scriptFile);
    109      if(script != NULL)
     106     if(scriptIsOk)
    110107     {
    111108     if(!(script->selectFunction(this->functionName,0)) )
     
    115112     }
    116113}
     114
     115
     116void ScriptTrigger::setScript(const std::string& file)
     117{
     118  ScriptManager* scriptManager = ScriptManager::getInstance();
     119  script = scriptManager->getScriptByFile(file);
     120  if(script != NULL)
     121    scriptIsOk = true;
     122
     123}
  • branches/script_engine/src/lib/script_engine/script_trigger.h

    r8208 r8211  
    88#include "vector.h"
    99#include "script_manager.h"
     10#include "script.h"
    1011
    1112class ScriptTrigger : public WorldEntity
     
    1718    ///LOADING
    1819    virtual void loadParams(const TiXmlElement* root);
    19    
    20    
     20
     21
    2122    /// DO WORK
    2223    virtual void tick(float timestep);
     
    3031    void setRadius(const float radius) { if(radius>0) this->radius = radius; }
    3132    void setDelay(const float time){if(delay>0) this->delay = delay; }
    32     void setScript(const std::string& script){ this->scriptFile = script; }
     33    void setScript(const std::string& file);
    3334    void setFunction(const std::string& function){ this->functionName = function; }
    3435
     
    4041    float        radius;
    4142    float        delay;
    42     std::string  scriptFile;
     43    Script*      script;
    4344    std::string  functionName;
    4445
    4546    //for internal use
    4647    bool         scriptCalled;
    47     bool         callScript;
    48     bool         triggered;
    49     float        timer;
     48    bool         scriptIsOk;
    5049
    5150};
Note: See TracChangeset for help on using the changeset viewer.