Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2009, 2:22:00 AM (15 years ago)
Author:
rgrieder
Message:

Merged resource2 branch back to trunk.

IMPORTANT NOTE:
Upon this merge you need to specifically call your data directory "data_extern" when checking it out (when you don't provide a name, it will be just called 'trunk').
The new CMake variable is EXTERNAL_DATA_DIRECTORY. DATA_DIRECTORY now points to the one the source part of the repository.
UPDATE YOUR DATA DIRECTORY AS WELL!!!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/Script.cc

    r3196 r5695  
    2929#include "Script.h"
    3030
    31 #include <tinyxml/ticpp.h>
    3231#include "core/CoreIncludes.h"
    33 #include "core/LuaBind.h"
     32#include "core/LuaState.h"
     33#include "core/XMLPort.h"
    3434
    3535namespace orxonox
    3636{
    37   CreateFactory(Script);
     37    CreateFactory(Script);
    3838
    39   Script::Script(BaseObject* creator) : BaseObject(creator)
    40   {
    41     RegisterObject(Script);
     39    Script::Script(BaseObject* creator) : BaseObject(creator)
     40    {
     41        RegisterObject(Script);
    4242
    43     code_ = "";
    44   }
     43        // Get a new LuaState
     44        luaState_ = new LuaState();
     45    }
    4546
    46   Script::~Script()
    47   {
    48   }
     47    Script::~Script()
     48    {
     49        if (this->isInitialized())
     50            delete luaState_;
     51    }
    4952
    50   /**
    51   @brief XML loading and saving.
    52   @param xmlelement The XML-element
    53   @param loading Loading (true) or saving (false)
    54    */
    55   void Script::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    56   {
    57     BaseObject::XMLPort(xmlelement, mode);
     53    void Script::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     54    {
     55        BaseObject::XMLPort(xmlelement, mode);
    5856
    59     code_ = xmlelement.GetText(false);
    60   }
     57        XMLPortParam(Script, "code", setCode, getCode, xmlelement, mode);
     58    }
    6159
    62   void Script::execute()
    63   {
    64     LuaBind& lua = LuaBind::getInstance();
    65     lua.loadString(this->code_);
    66     lua.run();
    67   }
     60    void Script::execute()
     61    {
     62        luaState_->doString(code_);
     63    }
    6864}
Note: See TracChangeset for help on using the changeset viewer.