Merge remote-tracking branch 'lethosor/qerror-script-name' into develop

develop
lethosor 2018-06-01 00:09:34 -04:00
commit 877bc4c14b
1 changed files with 6 additions and 2 deletions

@ -61,6 +61,10 @@ function dfhack.pcall(f, ...)
end end
function qerror(msg, level) function qerror(msg, level)
local name = dfhack.current_script_name()
if name and not tostring(msg):match(name) then
msg = name .. ': ' .. tostring(msg)
end
dfhack.error(msg, (level or 1) + 1, false) dfhack.error(msg, (level or 1) + 1, false)
end end
@ -562,7 +566,7 @@ function dfhack.run_script_with_env(envVars, name, flags, ...)
return script_code(...), env return script_code(...), env
end end
local function current_script_name() function dfhack.current_script_name()
local frame = 1 local frame = 1
while true do while true do
local info = debug.getinfo(frame, 'f') local info = debug.getinfo(frame, 'f')
@ -584,7 +588,7 @@ local function current_script_name()
end end
function dfhack.script_help(script_name, extension) function dfhack.script_help(script_name, extension)
script_name = script_name or current_script_name() script_name = script_name or dfhack.current_script_name()
extension = extension or 'lua' extension = extension or 'lua'
local full_name = script_name .. '.' .. extension local full_name = script_name .. '.' .. extension
local path = dfhack.internal.findScript(script_name .. '.' .. extension) local path = dfhack.internal.findScript(script_name .. '.' .. extension)