mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-26 04:23:44 +01:00
Minor refactoring
This commit is contained in:
parent
90adfb42c1
commit
e16c23c29c
24
init.lua
24
init.lua
@ -176,26 +176,25 @@ local function table_eq(T1, T2)
|
||||
end
|
||||
|
||||
avoid_loops[t1] = t2
|
||||
local t2keys = {}
|
||||
local t2tablekeys = {}
|
||||
local t2k, t2kv = {}, {}
|
||||
|
||||
for k in pairs(t2) do
|
||||
if type(k) == "table" then
|
||||
insert(t2tablekeys, k)
|
||||
if is_table(k) then
|
||||
insert(t2kv, k)
|
||||
end
|
||||
|
||||
t2keys[k] = true
|
||||
t2k[k] = true
|
||||
end
|
||||
|
||||
for k1, v1 in pairs(t1) do
|
||||
local v2 = t2[k1]
|
||||
if type(k1) == "table" then
|
||||
local ok
|
||||
for i = 1, #t2tablekeys do
|
||||
local tk = t2tablekeys[i]
|
||||
for i = 1, #t2kv do
|
||||
local tk = t2kv[i]
|
||||
if table_eq(k1, tk) and recurse(v1, t2[tk]) then
|
||||
remove(t2tablekeys, i)
|
||||
t2keys[tk] = nil
|
||||
remove(t2kv, i)
|
||||
t2k[tk] = nil
|
||||
ok = true
|
||||
break
|
||||
end
|
||||
@ -204,12 +203,12 @@ local function table_eq(T1, T2)
|
||||
if not ok then return end
|
||||
else
|
||||
if v2 == nil then return end
|
||||
t2keys[k1] = nil
|
||||
t2k[k1] = nil
|
||||
if not recurse(v1, v2) then return end
|
||||
end
|
||||
end
|
||||
|
||||
if next(t2keys) then return end
|
||||
if next(t2k) then return end
|
||||
return true
|
||||
end
|
||||
|
||||
@ -1174,7 +1173,7 @@ local function handle_drops_table(name, drop)
|
||||
local di = drop_items[i]
|
||||
|
||||
for j = 1, #di.items do
|
||||
if is_str(di.items[j]) then
|
||||
if not is_str(di.items[j]) then break end
|
||||
local dname, dcount = match(di.items[j], "(.*)%s*(%d*)")
|
||||
dcount = dcount and tonumber(dcount) or 1
|
||||
|
||||
@ -1204,7 +1203,6 @@ local function handle_drops_table(name, drop)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for item, count in pairs(drop_sure) do
|
||||
craftguide.register_craft({
|
||||
|
Loading…
Reference in New Issue
Block a user