1
0
forked from redo/BlockLua
This commit is contained in:
2025-10-05 19:50:29 -04:00
parent f447c039c7
commit 01f216f31e
16 changed files with 2824 additions and 2596 deletions

View File

@@ -9,32 +9,32 @@ _bllua_on_unload = {}
-- Utility for getting the current filename
function debug.getfilename(level)
if type(level) == 'number' then level = level+1 end
local info = debug.getinfo(level)
if not info then return nil end
local filename = info.source:match('^%-%-%[%[([^%]]+)%]%]')
return filename
if type(level) == 'number' then level = level + 1 end
local info = debug.getinfo(level)
if not info then return nil end
local filename = info.source:match('^%-%-%[%[([^%]]+)%]%]')
return filename
end
-- Called when pcall fails on a ts->lua call, used to print detailed error info
function _bllua_on_error(err)
err = err:match(': (.+)$') or err
local tracelines = {err}
local level = 2
while true do
local info = debug.getinfo(level)
if not info then break end
local filename = debug.getfilename(level) or info.short_src
local funcname = info.name
if funcname=='dofile' then break end
table.insert(tracelines, string.format('%s:%s in function \'%s\'',
filename,
info.currentline==-1 and '' or info.currentline..':',
funcname
))
level = level+1
end
return table.concat(tracelines, '\n')
err = err:match(': (.+)$') or err
local tracelines = { err }
local level = 2
while true do
local info = debug.getinfo(level)
if not info then break end
local filename = debug.getfilename(level) or info.short_src
local funcname = info.name
if funcname == 'dofile' then break end
table.insert(tracelines, string.format('%s:%s in function \'%s\'',
filename,
info.currentline == -1 and '' or info.currentline .. ':',
funcname
))
level = level + 1
end
return table.concat(tracelines, '\n')
end
_bllua_ts.echo(' Executed bllua-env.lua')