Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 15, 2006, 5:33:25 PM (18 years ago)
Author:
snellen
Message:

helicopter scripted

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

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/coord/p_node.h

    r8186 r8485  
    103103  /** @returns the absolute position */
    104104  inline const Vector& getAbsCoor () const { return this->absCoordinate; };
     105  /** @returns the absolute X coordinate. */
     106  inline float getAbsCoorX() { return this->absCoordinate.x; };
     107  /** @returns the absolute Y Coordinate */
     108  inline float getAbsCoorY() { return this->absCoordinate.y; };
     109  /** @returns the absolute Z Coordinate */
     110  inline float getAbsCoorZ() { return this->absCoordinate.z; };
     111 
    105112  void shiftCoor (const Vector& shift);
    106113  void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); };
  • branches/script_engine/src/lib/script_engine/script.cc

    r8408 r8485  
    192192 bool Script::pushParam(int param, std::string& toFunction)
    193193 {
    194    if(currentFunction.compare(toFunction) == 0)
     194   if(currentFunction == toFunction)
    195195   {
    196196     lua_pushnumber(luaState, (lua_Number) param);
     
    267267       returnCount--;
    268268     }
     269     else
     270       printf("ERROR: Form %s : trying to retreive non bolean value",this->currentFile.c_str());
    269271   }
    270272   return returnValue;
     
    313315 }
    314316
     317 bool Script::registerStandartClasses()
     318 {
     319   bool success = false;
     320   
     321   //success = this->registerClass(std::string("Vector"));
     322   
     323   return success;
     324 }
     325 
     326 
     327 bool Script::registerClass( const std::string& className)
     328 {
     329   BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
     330   //printf("The script class for %s is at %p \n",className.c_str(),scriptClass);
     331   WorldObject tmpObj;
     332   if (scriptClass != NULL)
     333   {
     334     tmpObj.type = className;
     335     if( !classIsRegistered(className) )
     336     {
     337       static_cast<ScriptClass*>(scriptClass)->registerClass(this);
     338       tmpObj.name = "";
     339       registeredObjects.push_back(tmpObj);
     340       return true;
     341     }
     342   }
     343   return false;
     344 
     345 }
    315346
    316347 bool Script::classIsRegistered(const std::string& type)
  • branches/script_engine/src/lib/script_engine/script.h

    r8408 r8485  
    5858
    5959    int  reportError(int error);                      //!< Get errormessage from the lua stack and print it.
     60    bool registerStandartClasses();                   //!< Register all the classes that the script might need
     61    bool registerClass(const std::string& className); //!< Register a class but dont add any instances
    6062    bool classIsRegistered(const std::string& type);  //!< Checks wheter the class "type" has already been registered with the script
    6163    bool objectIsAdded(const std::string& name);      //!< Checks wheter the object "name" has already been added to the script
  • branches/script_engine/src/lib/util/executor/executor_lua.h

    r8408 r8485  
    183183
    184184
     185///////////
     186//// 3 ////
     187///////////
     188//! Executes a Function with a lua_State* parameter.
     189template<class T, typename type0, typename type1, typename type2> class ExecutorLua3 : public Executor
     190{
     191  public:
     192    /**
     193   * @brief Constructor of a ExecutorXML
     194   * @param function a Function to call
     195     */
     196    ExecutorLua3(void(T::*function)(type0, type1, type2))
     197  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())
     198    {
     199      this->functionPointer = function;
     200      this->functorType = Executor_Objective | Executor_NoLoadString;
     201    }
     202
     203    /**
     204     * @brief executes the Command on BaseObject
     205     * @param object the BaseObject to execute this Executor on
     206     * @param loadString ignored in this case
     207     */
     208    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     209    {
     210      PRINTF(1)("no usefull executor\n");
     211    }
     212
     213    virtual void operator()(BaseObject* object, int& count, void* values) const
     214    {
     215      lua_State* state = (lua_State*)values;
     216      count = 0;
     217
     218      (dynamic_cast<T*>(object)->*(functionPointer))(
     219          fromLua<type0>(state, 1),
     220          fromLua<type1>(state, 2),
     221          fromLua<type2>(state, 3) );
     222    }
     223
     224    /**
     225     * @returns a _new_ Copy of this Executor
     226     */
     227    virtual Executor* clone () const
     228    {
     229      return new ExecutorLua3<T, type0, type1, type2>(this->functionPointer);
     230    }
     231  private:
     232    void          (T::*functionPointer)(type0, type1, type2);
     233};
     234
    185235
    186236
     
    210260      this->functorType = Executor_Objective | Executor_NoLoadString;
    211261    }
    212 
     262   
    213263    /**
    214264     * @brief executes the Command on BaseObject
Note: See TracChangeset for help on using the changeset viewer.