Changeset 5695 for code/trunk/src/orxonox/objects
- Timestamp:
- Aug 30, 2009, 2:22:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/resource2 (added) merged: 3373-3374,5594,5597,5610-5611,5614,5624,5641,5644-5646,5650-5664,5667-5672,5682-5684,5688-5691,5694
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/Level.cc
r3325 r5695 53 53 this->registerVariables(); 54 54 this->xmlfilename_ = this->getFilename(); 55 56 if (this->xmlfilename_.length() >= Core::getMediaPathString().length())57 this->xmlfilename_ = this->xmlfilename_.substr(Core::getMediaPathString().length());58 55 } 59 56 … … 101 98 mask.include(Class(OverlayGroup)); // HACK to include the ChatOverlay 102 99 103 this->xmlfile_ = new XMLFile( Core::getMediaPathString() + this->xmlfilename_, mask);100 this->xmlfile_ = new XMLFile(mask, this->xmlfilename_); 104 101 105 102 Loader::open(this->xmlfile_); -
code/trunk/src/orxonox/objects/Script.cc
r3196 r5695 29 29 #include "Script.h" 30 30 31 #include <tinyxml/ticpp.h>32 31 #include "core/CoreIncludes.h" 33 #include "core/LuaBind.h" 32 #include "core/LuaState.h" 33 #include "core/XMLPort.h" 34 34 35 35 namespace orxonox 36 36 { 37 CreateFactory(Script);37 CreateFactory(Script); 38 38 39 Script::Script(BaseObject* creator) : BaseObject(creator)40 {41 RegisterObject(Script);39 Script::Script(BaseObject* creator) : BaseObject(creator) 40 { 41 RegisterObject(Script); 42 42 43 code_ = ""; 44 } 43 // Get a new LuaState 44 luaState_ = new LuaState(); 45 } 45 46 46 Script::~Script() 47 { 48 } 47 Script::~Script() 48 { 49 if (this->isInitialized()) 50 delete luaState_; 51 } 49 52 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); 58 56 59 code_ = xmlelement.GetText(false);60 }57 XMLPortParam(Script, "code", setCode, getCode, xmlelement, mode); 58 } 61 59 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 } 68 64 } -
code/trunk/src/orxonox/objects/Script.h
r3196 r5695 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport Script : public BaseObject40 {39 class _OrxonoxExport Script : public BaseObject 40 { 41 41 public: 42 Script(BaseObject* creator); 43 ~Script(); 44 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 void execute(); 42 Script(BaseObject* creator); 43 ~Script(); 44 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 void execute(); 46 47 void setCode(const std::string& code) { code_ = code; } 48 const std::string& getCode() const { return code_; } 46 49 47 50 private: 48 std::string code_; 49 }; 51 std::string code_; 52 LuaState* luaState_; 53 }; 50 54 } 51 55
Note: See TracChangeset
for help on using the changeset viewer.