- Timestamp:
- Mar 28, 2010, 7:16:12 PM (15 years ago)
- Location:
- code/branches/gamestate
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestate/data/lua/Debugger.lua
r6624 r6626 2 2 --{{{ history 3 3 4 --28/03/10 ORX Adjusted show() to work with the Orxonox resource system 4 5 --15/03/06 DCN Created based on RemDebug 5 6 --28/04/06 DCN Update for Lua 5.1 … … 396 397 after = tonumber(after or before) 397 398 398 if not string.find(file,'%.') then file = file..'.lua' end 399 400 local f = io.open(file,'r') 401 if not f then 402 --{{{ try to find the file in the path 399 -- Try to find the file in the Orxonox resources 400 local text = luaState:getSourceCode(file) 401 402 if text == "" then 403 if not string.find(file,'%.') then file = file..'.lua' end 404 405 local f = io.open(file,'r') 406 if not f then 407 --{{{ try to find the file in the path 403 408 404 -- 405 -- looks for a file in the package path 406 -- 407 local path = package.path or LUA_PATH or '' 408 for c in string.gmatch (path, "[^;]+") do 409 local c = string.gsub (c, "%?%.lua", file) 410 f = io.open (c,'r') 409 -- 410 -- looks for a file in the package path 411 -- 412 local path = package.path or LUA_PATH or '' 413 for c in string.gmatch (path, "[^;]+") do 414 local c = string.gsub (c, "%?%.lua", file) 415 f = io.open (c,'r') 416 if f then 417 break 418 end 419 end 420 421 --}}} 422 411 423 if f then 412 break 413 end 414 end 415 416 --}}} 417 if not f then 418 io.write('Cannot find '..file..'\n') 419 return 420 end 421 end 422 424 -- Read file into 'text' 425 text = f:read("*a") 426 f:close() 427 else 428 io.write('Cannot find '..file..'\n') 429 return 430 end 431 end 432 end 433 434 -- Transform line endings to \n 435 text :gsub("\r\n", "\n") -- Windows to Unix 436 text:gsub("\r", "\n") -- Mac to Unix 437 if text[-1] ~= "\n" then 438 text = text.."\n" 439 end 440 -- Print requested lines 423 441 local i = 0 424 for l in f:lines() do442 for l in text:gmatch("[^\n]*[\n]") do 425 443 i = i + 1 426 444 if i >= (line-before) then 427 445 if i > (line+after) then break end 428 446 if i == line then 429 io.write(i..'***\t'..l..'\n') 430 else 431 io.write(i..'\t'..l..'\n') 432 end 433 end 434 end 435 436 f:close() 437 447 io.write(i..'***\t'..l) 448 else 449 io.write(i..'\t'..l) 450 end 451 end 452 end 438 453 end 439 454 … … 611 626 file = string.sub(file, 2) 612 627 end 613 if IsWindows then file = string.lower(file) end 628 -- Orxonox changes: Our resource system is case sensisive, even on Windows 629 --if IsWindows then file = string.lower(file) end 614 630 615 631 if not line then -
code/branches/gamestate/src/libraries/core/LuaState.cc
r6625 r6626 135 135 136 136 std::string chunkname; 137 if (sourceFileInfo != NULL && !sourceFileInfo->fileSystemPath.empty())137 if (sourceFileInfo != NULL) 138 138 { 139 139 // Provide lua_load with the filename for debug purposes 140 140 // The '@' is a Lua convention to identify the chunk name as filename 141 chunkname = '@' + sourceFileInfo->file SystemPath;142 } 143 else 144 { 145 // Use the beginning of thecode string to identify the chunk146 chunkname = code .substr(0, 80);141 chunkname = '@' + sourceFileInfo->filename; 142 } 143 else 144 { 145 // Use the code string to identify the chunk 146 chunkname = code; 147 147 } 148 148 … … 195 195 } 196 196 197 //! Returns the content of a file 198 std::string LuaState::getSourceCode(const std::string& filename) 199 { 200 shared_ptr<ResourceInfo> info = Resource::getInfo(filename); 201 if (info == NULL) 202 return ""; 203 else 204 return Resource::open(info)->getAsString(); 205 } 206 197 207 #if LUA_VERSION_NUM != 501 198 208 const char * LuaState::lua_Chunkreader(lua_State *L, void *data, size_t *size) -
code/branches/gamestate/src/libraries/core/LuaState.h
r6442 r6626 80 80 void luaLog(unsigned int level, const std::string& message); // tolua_export 81 81 bool fileExists(const std::string& filename); // tolua_export 82 std::string getSourceCode(const std::string& filename); // tolua_export 82 83 83 84 const std::stringstream& getOutput() const { return output_; }
Note: See TracChangeset
for help on using the changeset viewer.