Changeset 1029 for code/trunk/src/orxonox/core
- Timestamp:
- Apr 11, 2008, 7:01:02 PM (17 years ago)
- Location:
- code/trunk/src/orxonox/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/core/Script.cc
r1024 r1029 49 49 luaState_ = lua_open(); 50 50 luaSource_ = ""; 51 #if LUA_VERSION_NUM == 501 51 52 luaL_openlibs(luaState_); 53 #else 54 luaopen_base(luaState_); 55 luaopen_string(luaState_); 56 luaopen_table(luaState_); 57 luaopen_math(luaState_); 58 luaopen_io(luaState_); 59 luaopen_debug(luaState_); 60 #endif 52 61 tolua_orxonox_open(luaState_); 53 62 output_; … … 97 106 std::string init = "local scr = orxonox.Script:getInstance()\nprint = function(s)\nscr:luaPrint(s)\nend\n"; 98 107 init += luaSource_; 108 #if LUA_VERSION_NUM == 501 99 109 error = luaL_loadstring(luaState_, init.c_str()); 110 #else 111 error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, init.c_str(), "init"); 112 #endif 100 113 if (error == 0) 101 114 error = lua_pcall(luaState_, 0, 0, 0); 102 115 if (error != 0) COUT(2) << "Error in Lua-script: " << lua_tostring(luaState_, -1) << std::endl; 103 116 } 104 105 117 106 118 unsigned int Script::getNextQuote(const std::string& text, unsigned int start) … … 143 155 std::map<unsigned int, bool>::iterator it2 = it; 144 156 bool bBetweenQuotes = false; 145 bool bBetweenTags = false;146 157 unsigned int pos = 0; 147 158 while ((pos = getNextQuote(text, pos)) != std::string::npos) -
code/trunk/src/orxonox/core/Script.h
r1021 r1029 30 30 void luaPrint(std::string str); // tolua_export 31 31 32 #if LUA_VERSION_NUM != 501 33 inline const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;}; 34 #endif 35 32 36 inline lua_State* getLuaState() { return luaState_; }; 33 37 inline std::string getLuaOutput() { return output_; };
Note: See TracChangeset
for help on using the changeset viewer.