From e4baa92aae537921dd17873328a95ab17afcfdfc Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 29 Mar 2012 23:29:54 +0200 Subject: 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 --- scripts/lua/libmana.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts') 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 = {} -- cgit