2021-01-12 20:40:34 +01:00
|
|
|
|
|
|
|
-- help function for swap appliance node
|
|
|
|
-- typicaly between active and inactive appliance
|
|
|
|
function appliances.swap_node(pos, name)
|
|
|
|
local node = minetest.get_node(pos);
|
|
|
|
if (node.name == name) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
node.name = name;
|
|
|
|
minetest.swap_node(pos, node);
|
|
|
|
end
|
|
|
|
|
|
|
|
appliances.random = PcgRandom(os.time());
|
|
|
|
|
2021-03-26 17:15:55 +01:00
|
|
|
--
|
|
|
|
-- {
|
|
|
|
-- description = "", -- description text
|
|
|
|
-- icon = "", -- path to icon file, can be nil
|
|
|
|
-- width = 1, -- width of recipe (unified only)
|
|
|
|
-- height = 1, -- height of recipe (unified only)
|
|
|
|
-- dynamic_display_size = nil, -- unified callback only
|
|
|
|
-- }
|
|
|
|
--
|
|
|
|
function appliances.register_craft_type(type_name, type_def)
|
|
|
|
if appliances.have_unified then
|
|
|
|
unified_inventory.register_craft_type(type_name, {
|
|
|
|
description = type_def.description,
|
|
|
|
icon = type_def.icon,
|
|
|
|
width = type_def.width,
|
|
|
|
height = type_def.height,
|
|
|
|
dynamic_display_size = type_def.dynamic_display_size,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
if appliances.have_craftguide then
|
|
|
|
craftguide.register_craft_type(type_name, {
|
|
|
|
description = type_def.description,
|
|
|
|
icon = type_def.icon,
|
|
|
|
})
|
|
|
|
end
|
2021-03-27 13:07:39 +01:00
|
|
|
if appliances.have_i3 then
|
|
|
|
minetest.register_on_mods_loaded(function()
|
|
|
|
i3.register_craft_type(type_name, {
|
|
|
|
description = type_def.description,
|
|
|
|
icon = type_def.icon,
|
|
|
|
})
|
|
|
|
end)
|
|
|
|
end
|
2021-03-26 17:15:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--
|
|
|
|
-- {
|
|
|
|
-- type = "", -- type name
|
|
|
|
-- output = "", -- item string
|
2021-03-31 18:53:43 +02:00
|
|
|
-- items = {""}, -- input items
|
2021-03-26 17:15:55 +01:00
|
|
|
-- }
|
|
|
|
--
|
|
|
|
function appliances.register_craft(craft_def)
|
|
|
|
if appliances.have_unified then
|
|
|
|
unified_inventory.register_craft({
|
|
|
|
type = craft_def.type,
|
|
|
|
output = craft_def.output,
|
|
|
|
items = craft_def.items,
|
|
|
|
})
|
|
|
|
end
|
2021-03-27 13:07:39 +01:00
|
|
|
if appliances.have_craftguide or appliances.have_i3 then
|
2021-08-16 10:09:11 +02:00
|
|
|
local items = table.concat(craft_def.items, ",");
|
2021-03-27 13:07:39 +01:00
|
|
|
|
|
|
|
if appliances.have_craftguide then
|
|
|
|
craftguide.register_craft({
|
|
|
|
type = craft_def.type,
|
|
|
|
result = craft_def.output,
|
|
|
|
items = items,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
if appliances.have_i3 then
|
|
|
|
minetest.register_on_mods_loaded(function()
|
|
|
|
i3.register_craft({
|
|
|
|
type = craft_def.type,
|
|
|
|
result = craft_def.output,
|
|
|
|
items = items,
|
|
|
|
})
|
|
|
|
end)
|
|
|
|
end
|
2021-03-26 17:15:55 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|