diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-29 23:29:54 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-30 21:36:41 +0200 |
commit | e4baa92aae537921dd17873328a95ab17afcfdfc (patch) | |
tree | db5cc3104df925677b6684da296f61aaacb6e6a4 /scripts | |
parent | 2f68a9da7121ab2adaa70ff257577ee596b4c4ee (diff) | |
download | manaserv-e4baa92aae537921dd17873328a95ab17afcfdfc.tar.gz manaserv-e4baa92aae537921dd17873328a95ab17afcfdfc.tar.xz manaserv-e4baa92aae537921dd17873328a95ab17afcfdfc.zip |
Fixed Lua error reporting for NPC scripts
This was due to a naming conflict between the 'debug' function I had recently
introduced and the 'debug' library provided by Lua. This caused problems when
trying to use debug.traceback for printing a backtrace of the error.
There's multiple ways to avoid the naming conflict. I opted for writing the
related helper functions in all-caps.
Also added an ERROR log function now. As Erik pointed out, there is no conflict
anymore with Lua's 'error' function with the new naming style.
Reviewed-by: Erik Schilling
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lua/libmana.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua index 777d8e0..d133e57 100644 --- a/scripts/lua/libmana.lua +++ b/scripts/lua/libmana.lua @@ -37,9 +37,10 @@ world = setmetatable({}, { }) -- Some convenient shortcuts for the different log levels -function warn(...) log(LOG_WARN, table.concat({...}, " ")) end -function info(...) log(LOG_INFO, table.concat({...}, " ")) end -function debug(...) log(LOG_DEBUG, table.concat({...}, " ")) end +function ERROR(...) log(LOG_ERROR, table.concat({...}, " ")) end +function WARN(...) log(LOG_WARN, table.concat({...}, " ")) end +function INFO(...) log(LOG_INFO, table.concat({...}, " ")) end +function DEBUG(...) log(LOG_DEBUG, table.concat({...}, " ")) end -- Array containing the function registered by atinit. local init_fun = {} |