forked from Mirrorlandia_minetest/minetest
master #6
@ -46,11 +46,18 @@ local register_functions = {
|
||||
register_on_mapblocks_changed = 0,
|
||||
}
|
||||
|
||||
local function regex_escape(s)
|
||||
return s:gsub("(%W)", "%%%1")
|
||||
end
|
||||
|
||||
---
|
||||
-- Create an unique instrument name.
|
||||
-- Generate a missing label with a running index number.
|
||||
--
|
||||
local counts = {}
|
||||
local worldmods_path = regex_escape(core.get_worldpath())
|
||||
local user_path = regex_escape(core.get_user_path())
|
||||
local builtin_path = regex_escape(core.get_builtin_path())
|
||||
local function generate_name(def)
|
||||
local class, label, func_name = def.class, def.label, def.func_name
|
||||
if label then
|
||||
@ -65,7 +72,16 @@ local function generate_name(def)
|
||||
local index_id = def.mod .. (class or func_name)
|
||||
local index = counts[index_id] or 1
|
||||
counts[index_id] = index + 1
|
||||
return format("%s[%d] %s", class or func_name, index, class and func_name or ""):trim()
|
||||
local info = debug.getinfo(def.func)
|
||||
local modpath = regex_escape(core.get_modpath(def.mod) or "")
|
||||
local source = info.source
|
||||
if modpath ~= "" then
|
||||
source = source:gsub(modpath, def.mod)
|
||||
end
|
||||
source = source:gsub(worldmods_path, "")
|
||||
source = source:gsub(builtin_path, "builtin" .. DIR_DELIM)
|
||||
source = source:gsub(user_path, "")
|
||||
return format("%s[%d] %s#%s", class or func_name, index, source, info.linedefined)
|
||||
end
|
||||
|
||||
---
|
||||
|
@ -77,7 +77,7 @@ local Formatter = {
|
||||
end
|
||||
}
|
||||
|
||||
local widths = { 55, 9, 9, 9, 5, 5, 5 }
|
||||
local widths = { 80, 9, 9, 9, 5, 5, 5 }
|
||||
local txt_row_format = sprintf(" %%-%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds", unpack(widths))
|
||||
|
||||
local HR = {}
|
||||
|
Loading…
Reference in New Issue
Block a user