Changeset 6660 for code/branches/gamestate/data/lua
- Timestamp:
- Mar 31, 2010, 12:04:30 AM (15 years ago)
- Location:
- code/branches/gamestate/data/lua
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestate/data/lua/Debugger.lua
r6626 r6660 433 433 434 434 -- Transform line endings to \n 435 text 435 text:gsub("\r\n", "\n") -- Windows to Unix 436 436 text:gsub("\r", "\n") -- Mac to Unix 437 437 if text[-1] ~= "\n" then -
code/branches/gamestate/data/lua/LuaStateInit.lua
r6629 r6660 17 17 dofile = function(filename) 18 18 luaState:doFile(filename) 19 -- Required because the C++ function cannot return whatever might be on the stack19 -- Required because if the file returns a table, it cannot be passed through the C++ function 20 20 return LuaStateReturnValue -- C-injected global variable 21 21 end … … 26 26 include = function(filename) 27 27 luaState:includeFile(filename) 28 -- Required because the C++ function cannot return whatever might be on the stack28 -- Required because if the file returns a table, it cannot be passed through the C++ function 29 29 return LuaStateReturnValue -- C-injected global variable 30 30 end … … 44 44 _LOADED = {} 45 45 end 46 if not _LOADED[moduleName]then46 if _LOADED[moduleName] == nil then 47 47 -- save old value 48 48 local _REQUIREDNAME_OLD = _REQUIREDNAME 49 49 _REQUIREDNAME = moduleName 50 50 luaState:doFile(moduleName .. ".lua") 51 _LOADED[moduleName] = LuaStateReturnValue 51 -- LuaStateReturnValue is required because if the file returns a table, 52 -- it cannot be passed through the C++ function 53 if LuaStateReturnValue == nil then -- C-injected global variable 54 LuaStateReturnValue = true 55 end 56 _LOADED[moduleName] = LuaStateReturnValue -- This entry must never be nil 52 57 -- restore old value 53 58 _REQUIREDNAME = _REQUIREDNAME_OLD … … 55 60 return _LOADED[moduleName] 56 61 end 62 63 64 -- Include command line debugger for lua 5.1 65 -- Note: It doesn't work if the IOConsole was started. Then we replace pause() with a warning 66 if _VERSION ~= "Lua 5.0" and not luaState:usingIOConsole() then 67 require("Debugger") 68 else 69 -- Fallback pause function 70 pause = function() 71 logMessage(2, [["Warning: debug() called in Lua, but Debugger is not active. 72 Do you have the IOConsole disabled and are you using Lua version 5.1?"]]) 73 end 74 end 75 76 -- General error handler that gets called whenever an error happens at runtime 77 errorHandler = function(err) 78 -- Display the error message 79 if type(err) == "string" then 80 logMessage(1, "Lua runtime error: "..err) 81 end 82 83 -- Start debugger if possible 84 if _LOADED and _LOADED["Debugger"] ~= nil then 85 pause() 86 else 87 -- Fallback: print stack trace 88 debug.traceback(nil, "", 2) 89 end 90 return err -- Hello Lua debugger user! Please type 'set 2' to get to the 91 -- actual position in the stack where the error occurred 92 end 93 57 94 58 95 -- Convenience function for console commands … … 71 108 return orxonox.SettingsConfigFile:getInstance():tconfig(section, entry, value) 72 109 end 73 74 -- Include command line debugger for lua 5.175 if _VERSION ~= "Lua 5.0" then76 require("Debugger")77 end
Note: See TracChangeset
for help on using the changeset viewer.