Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8978 in orxonox.OLD


Ignore:
Timestamp:
Jul 1, 2006, 2:48:17 PM (18 years ago)
Author:
snellen
Message:

perpared possibility to add the script object to the lua script itself (so that all objects can be added from within the script ), prepared possibility to create triggers form within a script

Location:
branches/single_player_map/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/lib/script_engine/script.cc

    r8783 r8978  
    2424
    2525#include "class_list.h"
     26// uncommet this when the std:string and the const bug is fixed
     27//CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT,
     28//                               addMethod("addObject", ExecutorLua2<Script,std::string,std::string>(&Script::addObject))
     29//                               ):
    2630
    2731Script::Script(const TiXmlElement* root)
     
    7377bool Script::loadFile(const std::string& filename)
    7478 {
    75 
     79   this->setName(filename);
    7680   std::string filedest(ResourceManager::getInstance()->getDataDir());
    7781   filedest += "scripts/" + filename;
     
    9397     {
    9498      currentFile = filename;
     99      //this->addThisScript();
    95100      return true;
    96101     }
     
    323328 }
    324329
     330
     331void Script::addThisScript()
     332{
     333  BaseObject* scriptClass = ClassList::getObject("Script", CL_SCRIPT_CLASS);
     334   if (scriptClass != NULL)
     335   {
     336     static_cast<ScriptClass*>(scriptClass)->registerClass(this);
     337     static_cast<ScriptClass*>(scriptClass)->insertObject(this, this, false);
     338   }
     339}
     340
    325341 int Script::reportError(int error)
    326342 {
  • branches/single_player_map/src/lib/script_engine/script.h

    r8711 r8978  
    3131    void loadFileNoRet(const std::string& filename) { loadFile(filename); };
    3232    bool loadFile(const std::string& filename);
    33     void addObject(const std::string& className, const std::string& objectName);
     33    void addObject( const std::string& className,const std::string& objectName);
    3434
    3535    /// QUERRYING
     
    6161
    6262  private:
    63 
     63    void addThisScript();
    6464    int  reportError(int error);                      //!< Get errormessage from the lua stack and print it.
    6565    bool registerStandartClasses();                   //!< Register all the classes that the script might need
  • branches/single_player_map/src/world_entities/script_trigger.cc

    r8894 r8978  
    1414*/
    1515
    16 
    1716#include "script_trigger.h"
    1817#include "class_list.h"
     
    2322
    2423CREATE_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))
     24                          //Position
     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                     //Set values
     30                    // ->addMethod("setTarget", ExecutorLua1<ScriptTrigger, std::string >(&ScriptTrigger::setTarget))
     31                    // ->addMethod("setTriggerParent", ExecutorLua1<ScriptTrigger, std::string >(&ScriptTrigger::setTriggerParent))
     32                     ->addMethod("setTriggerLasts", ExecutorLua1<ScriptTrigger, bool >(&ScriptTrigger::setTriggerLasts))
     33                     ->addMethod("setInvert", ExecutorLua1<ScriptTrigger, bool >(&ScriptTrigger::setInvert))
     34                     ->addMethod("setRadius", ExecutorLua1<ScriptTrigger, float >(&ScriptTrigger::setRadius))
     35                     //->addMethod("setScript", ExecutorLua1<ScriptTrigger, std::string >(&ScriptTrigger::setScript))
     36                     //->addMethod("setFunction", ExecutorLua1<ScriptTrigger, std::string >(&ScriptTrigger::setFunction))
     37                     ->addMethod("setDebugDraw", ExecutorLua1<ScriptTrigger, bool >(&ScriptTrigger::setInvert))
    2938                       );
    3039
     
    92101    LoadParam(root, "radius", this, ScriptTrigger, setRadius)
    93102        .describe("the fileName of the script, that should be triggered by this script trigger")
    94         .defaultValues(0);
    95     LoadParam(root, "delay", this, ScriptTrigger, setDelay)
    96         .describe("the delay after which the funtion sould be triggered")
    97103        .defaultValues(0);
    98104    LoadParam(root, "worldentity", this, ScriptTrigger, setTarget)
  • branches/single_player_map/src/world_entities/script_trigger.h

    r8894 r8978  
    3838    void setInvert(const bool inv) { this->invert = invert; }
    3939    void setRadius(const float radius) { if(radius>0) this->radius = radius; }
    40     void setDelay(const float time){if(delay>0) this->delay = delay; }
    4140    void setScript(const std::string& file);
    4241    void setFunction(const std::string& function){ this->functionName = function;}
Note: See TracChangeset for help on using the changeset viewer.