Tidy up registration reporting

This commit is contained in:
Aaron Suen 2020-07-16 07:29:11 -04:00
parent 84e5819753
commit f01be30a00
5 changed files with 17 additions and 15 deletions

View File

@ -1,9 +1,9 @@
-- LUALOCALS < ---------------------------------------------------------
-- SKIP: include nodecore
local dofile, error, minetest, pairs, rawget, rawset, setmetatable,
table, tostring, type
= dofile, error, minetest, pairs, rawget, rawset, setmetatable,
table, tostring, type
local dofile, error, ipairs, minetest, pairs, rawget, rawset,
setmetatable, table, tostring, type
= dofile, error, ipairs, minetest, pairs, rawget, rawset,
setmetatable, table, tostring, type
local table_concat, table_insert, table_sort
= table.concat, table.insert, table.sort
-- LUALOCALS > ---------------------------------------------------------
@ -69,12 +69,14 @@ do
local reg = "registered_"
local t = {}
for k, v in pairs(nodecore) do
if k:sub(1, #reg) == reg and type(v) == "table" and #v > 0 then
t[#t + 1] = k:sub(#reg + 1) .. "=" .. #v
if k:sub(1, #reg) == reg and type(v) == "table" then
local qty = 0
for _ in pairs(v) do qty = qty + 1 end
t[#t + 1] = "#" .. k .. " = " .. qty
end
end
table_sort(t)
nodecore.log("action", "registered: " .. table_concat(t, " "))
for _, x in ipairs(t) do nodecore.log("action", x) end
end
minetest.after(0, regreport)
end

View File

@ -165,7 +165,7 @@ local function tryall(rc, pos, node, data)
end
local craftidx, rebuildidx = nodecore.item_matching_index(
nodecore.craft_recipes,
nodecore.registered_recipes,
function(i) return i.indexkeys or {true} end,
"register_craft",
true,

View File

@ -5,8 +5,8 @@ local math_floor, table_insert
= math.floor, table.insert
-- LUALOCALS > ---------------------------------------------------------
local craft_recipes = {}
nodecore.craft_recipes = craft_recipes
local registered_recipes = {}
nodecore.registered_recipes = registered_recipes
local id = 0
@ -71,15 +71,15 @@ function nodecore.register_craft(recipe)
local newp = recipe.priority or 0
local min = 1
local max = #craft_recipes + 1
local max = #registered_recipes + 1
while max > min do
local try = math_floor((min + max) / 2)
local oldp = craft_recipes[try].priority or 0
local oldp = registered_recipes[try].priority or 0
if newp < oldp then
min = try + 1
else
max = try
end
end
table_insert(craft_recipes, min, recipe)
table_insert(registered_recipes, min, recipe)
end

View File

@ -87,7 +87,7 @@ end
minetest.after(0, function()
local t = {}
for _, v in ipairs(nodecore.craft_recipes) do t[#t + 1] = v end
for _, v in ipairs(nodecore.registered_recipes) do t[#t + 1] = v end
minetest.after(0, function()
for _, v in ipairs(t) do pressify(v) end
end)

View File

@ -13,7 +13,7 @@ local dntname = modname .. ":cookcheck"
local nevermatch = {}
local function nomatches(k)
local stack = ItemStack(k)
for _, rc in ipairs(nodecore.craft_recipes) do
for _, rc in ipairs(nodecore.registered_recipes) do
if rc.action == "cook" then
if nodecore.match({stack = stack}, rc.root.match) then return end
end