forked from minetest-mods/craftguide
Minor refactoring
This commit is contained in:
parent
c32feb44fc
commit
90adfb42c1
27
init.lua
27
init.lua
@ -1161,19 +1161,9 @@ core.register_craft = function(def)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function register_drops(name, def)
|
local function handle_drops_table(name, drop)
|
||||||
-- Code borrowed and modified from unified_inventory
|
-- Code borrowed and modified from unified_inventory
|
||||||
-- https://github.com/minetest-mods/unified_inventory/blob/master/api.lua
|
-- https://github.com/minetest-mods/unified_inventory/blob/master/api.lua
|
||||||
local drop = def.drop
|
|
||||||
|
|
||||||
if is_str(drop) and drop ~= name then
|
|
||||||
craftguide.register_craft({
|
|
||||||
type = "digging",
|
|
||||||
items = {name},
|
|
||||||
output = drop,
|
|
||||||
})
|
|
||||||
|
|
||||||
elseif is_table(drop) then
|
|
||||||
local drop_sure, drop_maybe = {}, {}
|
local drop_sure, drop_maybe = {}, {}
|
||||||
local drop_items = drop.items or {}
|
local drop_items = drop.items or {}
|
||||||
local max_items_left = drop.max_items
|
local max_items_left = drop.max_items
|
||||||
@ -1184,6 +1174,7 @@ local function register_drops(name, def)
|
|||||||
local di = drop_items[i]
|
local di = drop_items[i]
|
||||||
|
|
||||||
for j = 1, #di.items do
|
for j = 1, #di.items do
|
||||||
|
if is_str(di.items[j]) then
|
||||||
local dname, dcount = match(di.items[j], "(.*)%s*(%d*)")
|
local dname, dcount = match(di.items[j], "(.*)%s*(%d*)")
|
||||||
dcount = dcount and tonumber(dcount) or 1
|
dcount = dcount and tonumber(dcount) or 1
|
||||||
|
|
||||||
@ -1213,6 +1204,7 @@ local function register_drops(name, def)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for item, count in pairs(drop_sure) do
|
for item, count in pairs(drop_sure) do
|
||||||
craftguide.register_craft({
|
craftguide.register_craft({
|
||||||
@ -1230,6 +1222,19 @@ local function register_drops(name, def)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function register_drops(name, def)
|
||||||
|
local drop = def.drop
|
||||||
|
|
||||||
|
if is_str(drop) and drop ~= name then
|
||||||
|
craftguide.register_craft({
|
||||||
|
type = "digging",
|
||||||
|
items = {name},
|
||||||
|
output = drop,
|
||||||
|
})
|
||||||
|
elseif is_table(drop) then
|
||||||
|
handle_drops_table(name, drop)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handle_aliases(hash)
|
local function handle_aliases(hash)
|
||||||
|
Loading…
Reference in New Issue
Block a user