Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8178 in orxonox.OLD for branches/script_engine


Ignore:
Timestamp:
Jun 6, 2006, 8:47:40 PM (18 years ago)
Author:
snellen
Message:

added possibility to set the target as parent

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

Legend:

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

    r8171 r8178  
    2222{
    2323  //BaseObject::loadParams(root);
     24
     25  const TiXmlElement* scripttrigger= root->FirstChildElement("ScriptTrigger");
     26
     27  while( scripttrigger != NULL)
     28   {
     29     //TODO: generate script trigger in factory and let them load their params.
     30      scripttrigger = scripttrigger->NextSiblingElement("ScriptTrigger");
     31   }
    2432
    2533  const TiXmlElement* scripts = root->FirstChildElement("Scripts");
  • branches/script_engine/src/lib/script_engine/script_manager.h

    r8171 r8178  
    66
    77#include "script.h"
     8#include "script_trigger.h"
    89#include "base_object.h"
    910#include "luaincl.h"
     
    1819  Script script;
    1920};
     21
    2022
    2123class ScriptManager : public BaseObject
     
    5355
    5456
     57
     58
    5559};
    5660#endif
  • branches/script_engine/src/lib/script_engine/script_trigger.cc

    r8173 r8178  
    2323        .defaultValues("");
    2424    LoadParam(root, "abs-coor", this, ScriptTrigger, setAbsCoord)
    25         .describe("the fileName of the script, that should be triggered by this script trigger")
     25        .describe("where this script trigger should be located")
    2626        .defaultValues("");
    2727    LoadParam(root, "radius", this, ScriptTrigger, setRadius)
     
    3131        .describe("the delay after which the funtion sould be triggered")
    3232        .defaultValues(0);
     33    LoadParam(root, "worldentity", this, ScriptTrigger, setTargetName)
     34        .describe("The name of the target as it is in the *.oxw file")
     35        .defaultValues("");
     36    LoadParam(root, "worldentityisparent", this, ScriptTrigger, setIsParent)
     37        .describe("The name of the target as it is in the *.oxw file")
     38        .defaultValues("");
     39
    3340    }*/
    3441 timer = delay;
     
    3946void ScriptTrigger::tick(float timestep)
    4047{
    41  //if(triggered)
    42  //{
    43   //timer -= timestep;
    44   //if(timer < 0)
    45    callScript = true;
    46  //}
    47  
    4848
    4949 if((this->getAbsDirV()-target->getAbsDirV()).len() < radius)
    5050 {
    51   //triggered = true;
    52   if(!callOnce && callScript)
     51  if(!callOnce)
    5352   {
    5453    executeAction();
    5554   }
    56   else if(callOnce && !scriptCalled && callScript)
     55  else if(callOnce && !scriptCalled)
    5756  {
    5857   executeAction();
     
    7069     Script* script = scriptManager->getScriptByFile(this->scriptFile);
    7170     if(!(script->selectFunction(this->functionName,0)) )
    72        printf("Error: Selection of %s in %s failed.\n",functionName.c_str(), scriptFile.c_str());
     71       printf("Error ScriptTrigger: Selection of %s in %s failed.\n",functionName.c_str(), scriptFile.c_str());
    7372     if( !(script->executeFunction()) )
    74        printf("Execution of %s in %s failed\n",functionName.c_str(),scriptFile.c_str());
     73       printf("Error ScriptTrigger: Execution of %s in %s failed.\n",functionName.c_str(),scriptFile.c_str());
    7574}
  • branches/script_engine/src/lib/script_engine/script_trigger.h

    r8173 r8178  
    1919    virtual void executeAction();
    2020
    21     void setTarget(WorldEntity* target){ if(target!=NULL) this->target=target;}
     21    void setTarget(WorldEntity* target){ if(target!=NULL) this->target=target;if(worldEntityIsParent)this->setParent(target);}
     22    void setTargetName(std::string& name){this->targetName = name;}
    2223    void setCallOnce(bool call){this->callOnce = call;}
    2324    void setRadius(float radius){if(radius>0) this->radius = radius;}
     
    2627    void setFunction(std::string& function){this->functionName = function;}
    2728
     29    std::string getTargetName(){return targetName;}
     30
    2831  private:
    2932
    3033    WorldEntity* target;
    31     bool callOnce;
     34    std::string  targetName;
     35    bool         worldEntityIsParent;
     36    bool         callOnce;
    3237    bool scriptCalled;
    3338    float radius;
Note: See TracChangeset for help on using the changeset viewer.