Changeset 999 for code/branches/script/src/orxonox/core/Script.cc
- Timestamp:
- Apr 6, 2008, 2:43:12 AM (17 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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)
Note: See TracChangeset
for help on using the changeset viewer.