Changeset 999 for code/branches
- Timestamp:
- Apr 6, 2008, 2:43:12 AM (17 years ago)
- Location:
- code/branches/script
- Files:
-
- 1 deleted
- 4 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/script/cmake/FindLua.cmake
r998 r999 32 32 33 33 IF (NOT Lua_LIBRARIES) 34 FIND_LIBRARY(Lua_LIBRARIES lua50 l iblua34 FIND_LIBRARY(Lua_LIBRARIES lua50 lua 35 35 /usr/lib 36 36 /usr/local/lib 37 37 /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib/) 38 38 39 FIND_LIBRARY(Lua_LIBRARY lualib50 l iblualib39 FIND_LIBRARY(Lua_LIBRARY lualib50 lualib 40 40 /usr/lib 41 41 /usr/local/lib -
code/branches/script/src/orxonox/CMakeLists.txt
r996 r999 32 32 objects/weapon/BulletManager.cc 33 33 objects/weapon/WeaponStation.cc 34 script/Script.cc35 script/tolua_script.cc36 34 ) 37 35 … … 43 41 ${OGRE_LIBRARIES} 44 42 ${OIS_LIBRARIES} 45 ${Lua_LIBRARIES}46 ${ToLua_LIBRARIES}47 43 util 48 44 core -
code/branches/script/src/orxonox/core/CMakeLists.txt
r919 r999 18 18 XMLPort.cc 19 19 Tickable.cc 20 Script.cc 20 21 ) 21 22 … … 25 26 TARGET_LINK_LIBRARIES( core 26 27 util 28 ${Lua_LIBRARIES} 27 29 ) -
code/branches/script/src/orxonox/core/Loader.cc
r996 r999 33 33 #include "Debug.h" 34 34 #include "CoreIncludes.h" 35 #include " ../script/Script.h"35 #include "Script.h" 36 36 37 37 #include "util/tinyxml/ticpp.h" … … 110 110 // let Lua work this out: 111 111 //Script* lua; 112 Script::loadFile(level->getFile(), true);112 /*Script::loadFile(level->getFile(), true); 113 113 Script::init(Script::getLuaState()); 114 Script::run(); 114 Script::run();*/ 115 Script* lua = Script::getInstance(); 115 116 116 117 try … … 124 125 ticpp::Document xmlfile; 125 126 //xmlfile.ToDocument(); 126 xmlfile.Parse( *Script::getFileString(), true);127 xmlfile.Parse(lua->getLuaOutput(), true); 127 128 128 129 for ( ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++ ) -
code/branches/script/src/orxonox/core/Script.cc
r996 r999 39 39 40 40 #include "tolua++.h" 41 #include "tolua _script.h"41 #include "toluabind.h" 42 42 43 43 namespace orxonox 44 44 { 45 45 46 lua_State* Script::luaState_ = lua_open();47 //lua_State* Script::luaState_ = NULL;48 std::string Script::fileString_ = "";49 50 46 Script::Script() 51 47 { 52 } 53 54 Script::~Script() 55 { 56 57 } 58 59 /** 60 @brief Initializes a lua state 61 @param state_ the pointer of the lua_state to initialise 62 */ 63 void Script::init(lua_State *state_) 64 { 65 tolua_script_open(state_); 66 67 /* 68 #if LUA_VERSION_NUM == 501 69 luaL_openlibs(state_); 70 #else 71 luaopen_base(state_); 72 luaopen_table(state_); 73 luaopen_io(state_); 74 luaopen_string(state_); 75 luaopen_math(state_); 76 luaopen_debug(state_); 77 #endif 78 */ 48 luaState_ = lua_open(); 49 luaSource_ = ""; 50 tolua_something_open(luaState_); 79 51 } 80 52 81 53 void Script::luaPrint(std::string str) 82 54 { 83 fileString_ = str;55 output_ = str; 84 56 } 85 57 … … 100 72 101 73 char line[1024]; 74 std::string levelString = ""; 102 75 103 76 while (file.good() && !file.eof()) 104 77 { 105 78 file.getline(line, 1024); 106 fileString_+= line;79 levelString += line; 107 80 } 108 81 … … 110 83 //std::string output; 111 84 112 if (luaTags) fileString_ = replaceLuaTags(Script::fileString_);85 if (luaTags) luaSource_ = replaceLuaTags(levelString); 113 86 } 114 87 … … 117 90 int error = 0; 118 91 std::string init = "local scr = orxonox.Script:new()\n"; 119 init += fileString_;92 init += luaSource_; 120 93 error = luaL_loadstring(luaState_, init.c_str()); 121 94 if (error == 0) -
code/branches/script/src/orxonox/core/Script.h
r996 r999 21 21 { // tolua_export 22 22 public: 23 Script(); // tolua_export24 ~Script();23 inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } 24 inline ~Script() { Script::singletonRef = NULL; }; 25 25 26 staticvoid loadFile(std::string filename, bool luaTags);27 staticvoid init(lua_State *state_);26 void loadFile(std::string filename, bool luaTags); 27 //void init(lua_State *state_); 28 28 //void xmlToLua(); 29 staticvoid run();29 void run(); 30 30 void luaPrint(std::string str); // tolua_export 31 31 32 inline static lua_State* getLuaState() { return luaState_; }; 33 inline static std::string* getFileString() { return &fileString_; }; 32 inline lua_State* getLuaState() { return luaState_; }; 33 inline std::string getLuaOutput() { return output_; }; 34 //inline std::string* getFileString() { return &fileString_; }; 34 35 35 staticunsigned int getNextQuote(const std::string& text, unsigned int start);36 st atic std::string replaceLuaTags(const std::string& text);36 unsigned int getNextQuote(const std::string& text, unsigned int start); 37 std::string replaceLuaTags(const std::string& text); 37 38 38 39 private: 40 Script(); 41 static Script* singletonRef; 39 42 40 //std::list<std::string>& getLevelFileLines(); 41 42 static std::string fileString_; 43 static lua_State* luaState_; 43 std::string luaSource_; 44 std::string output_; 45 lua_State* luaState_; 44 46 45 47 }; // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.