Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8735 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 22, 2006, 4:54:55 PM (18 years ago)
Author:
snellen
Message:

script trigger can now be added to a script

Location:
branches/script_engine/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/defs/class_id.h

    r8717 r8735  
    250250  CL_SCRIPT                     =    0x00000651,
    251251  CL_SCRIPT_CLASS               =    0x00000652,
    252   CL_SCRIPT_TRIGGER             =    0x00000652,
     252  CL_SCRIPT_TRIGGER             =    0x00000653,
    253253
    254254
  • branches/script_engine/src/lib/lang/class_list.cc

    r8316 r8735  
    235235BaseObject* ClassList::getObject(const std::string& objectName, const std::string& className)
    236236{
     237
    237238  ClassList* cl = ClassList::getClassList(className);
    238239  if (cl != NULL)
  • branches/script_engine/src/lib/script_engine/script.cc

    r8711 r8735  
    114114 void Script::addObject(const std::string& className, const std::string& objectName)
    115115 {
    116    //printf("Script %p: I am about to add %s of class %s\n",this,objectName.c_str(),className.c_str());
     116  // printf("Script %p: I am about to add %s of class %s\n",this,objectName.c_str(),className.c_str());
    117117
    118118   BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
    119    //printf("The script class for %s is at %p \n",className.c_str(),scriptClass);
     119  // printf("The script class for %s is at %p \n",className.c_str(),scriptClass);
    120120   WorldObject tmpObj;
    121121   if (scriptClass != NULL)
     
    128128
    129129     BaseObject* object = ClassList::getObject(objectName, className);
    130      //printf("%s is at %p \n",objectName.c_str(),object);
     130    // printf("%s is at %p \n",objectName.c_str(),object);
    131131     if (object != NULL && !objectIsAdded(objectName))
    132132     {
  • branches/script_engine/src/world_entities/script_trigger.cc

    r8711 r8735  
    2121#include "state.h"
    2222
     23
     24CREATE_SCRIPTABLE_CLASS(ScriptTrigger, CL_SCRIPT_TRIGGER,
     25                            addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     26                                ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     27                                ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     28                                ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     29                       );
    2330
    2431
     
    4047  scriptIsOk = false;
    4148  triggerLasts = false;
     49  addToScript = false;
     50 
     51  if(root != NULL)
     52  {
     53   
    4254  loadParams(root);
    43 
     55   
     56  printf("%s \n",this->getName());
     57  BaseObject* object = ClassList::getObject(this->getName(), "ScriptTrigger");
     58 // printf("%s \n",object->getName());
     59 
     60  if(addToScript)
     61  {
     62    script->addObject( "ScriptTrigger", this->getName());
     63  }
     64 
     65  }
    4466}
    4567
     
    6082void ScriptTrigger::loadParams(const TiXmlElement* root)
    6183{
    62   if(root != NULL)
    63   {
     84
    6485    WorldEntity ::loadParams(root);
    6586
     
    97118        .describe("True if the script should only be called once")
    98119        .defaultValues("");
    99   }
    100 
     120    LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
     121        .describe("True if this scripttrigger should be aviable in the script")
     122        .defaultValues("");
    101123}
    102124
  • branches/script_engine/src/world_entities/script_trigger.h

    r8711 r8735  
    1414#include "script_manager.h"
    1515#include "script.h"
     16#include "script_class.h"
    1617
    1718class ScriptTrigger : public WorldEntity
     
    4243    void setFunction(const std::string& function){ this->functionName = function;}
    4344    void setDebugDraw(const bool draw) { this->doDebugDraw = draw; }
     45    void setAddToScript(const bool add) { this->addToScript = add; }
    4446
    4547    ///DRAWING
     
    5759    std::string  functionName;
    5860    bool         doDebugDraw;
    59 
     61    bool         addToScript;
    6062    //for internal use
    6163    bool         scriptCalled;
     
    6668};
    6769
     70
    6871#endif
  • branches/script_engine/src/world_entities/space_ships/helicopter.cc

    r8495 r8735  
    3636CREATE_FACTORY(Helicopter, CL_HELICOPTER);
    3737#include "script_class.h"
    38 //CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER, NULL);
    39 
     38CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER,
     39                        addMethod("moveUp", ExecutorLua1<Helicopter,bool>(&Helicopter::moveUp))
     40                            ->addMethod("moveDown", ExecutorLua1<Helicopter,bool>(&Helicopter::moveDown))
     41                            ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     42                            ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     43                            ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     44                            ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     45                           
     46                       );
    4047
    4148/**
  • branches/script_engine/src/world_entities/space_ships/helicopter.h

    r8711 r8735  
    8383};
    8484
    85 CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER,
    86                         addMethod("moveUp", ExecutorLua1<Helicopter,bool>(&Helicopter::moveUp))
    87                         ->addMethod("moveDown", ExecutorLua1<Helicopter,bool>(&Helicopter::moveDown))
    88                         ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    89                         ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
    90                         ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
    91                         ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    92                            
    93                         );
    94 
    95 
    9685#endif /* _HELICOPTERS_H */
Note: See TracChangeset for help on using the changeset viewer.