Doors: Allow arbitrary recipe to be passed, even nil

This allows mod makers to register their own recipies, including
none, to register doors.
This commit is contained in:
Auke Kok 2016-02-13 10:03:23 -08:00 committed by paramat
parent 8422f2ef52
commit 363b95c003
2 changed files with 27 additions and 13 deletions

@ -97,7 +97,7 @@ doors.get(pos)
inventory_image = "mod_door_inv.png", inventory_image = "mod_door_inv.png",
groups = {choppy = 1}, groups = {choppy = 1},
tiles = { "mod_door.png" }, tiles = { "mod_door.png" },
material = "default:wood", -- used to make a craft recipe recipe = craftrecipe,
sounds = default.node_sound_wood_defaults(), -- optional sounds = default.node_sound_wood_defaults(), -- optional
sound_open = sound play for open door, -- optional sound_open = sound play for open door, -- optional
sound_close = sound play for close door, -- optional sound_close = sound play for close door, -- optional

@ -352,14 +352,12 @@ function doors.register(name, def)
}, },
}) })
minetest.register_craft({ if def.recipe then
output = "doors:" .. name, minetest.register_craft({
recipe = { output = "doors:" .. name,
{def.material,def.material}; recipe = def.recipe,
{def.material,def.material}; })
{def.material,def.material}; end
}
})
_doors.registered_doors["doors:" .. name .. "_a"] = true _doors.registered_doors["doors:" .. name .. "_a"] = true
_doors.registered_doors["doors:" .. name .. "_b"] = true _doors.registered_doors["doors:" .. name .. "_b"] = true
@ -370,7 +368,11 @@ doors.register("door_wood", {
description = "Wooden Door", description = "Wooden Door",
inventory_image = "doors_item_wood.png", inventory_image = "doors_item_wood.png",
groups = { snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 }, groups = { snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 },
material = "group:wood", recipe = {
{"group:wood", "group:wood"},
{"group:wood", "group:wood"},
{"group:wood", "group:wood"},
}
}) })
doors.register("door_steel", { doors.register("door_steel", {
@ -379,7 +381,11 @@ doors.register("door_steel", {
inventory_image = "doors_item_steel.png", inventory_image = "doors_item_steel.png",
protected = true, protected = true,
groups = { snappy = 1, bendy = 2, cracky = 1, melty = 2, level = 2 }, groups = { snappy = 1, bendy = 2, cracky = 1, melty = 2, level = 2 },
material = "default:steel_ingot", recipe = {
{"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"},
}
}) })
doors.register("door_glass", { doors.register("door_glass", {
@ -387,8 +393,12 @@ doors.register("door_glass", {
description = "Glass Door", description = "Glass Door",
inventory_image = "doors_item_glass.png", inventory_image = "doors_item_glass.png",
groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 }, groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 },
material = "default:glass",
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
recipe = {
{"default:glass", "default:glass"},
{"default:glass", "default:glass"},
{"default:glass", "default:glass"},
}
}) })
doors.register("door_obsidian_glass", { doors.register("door_obsidian_glass", {
@ -396,8 +406,12 @@ doors.register("door_obsidian_glass", {
description = "Glass Door", description = "Glass Door",
inventory_image = "doors_item_obsidian_glass.png", inventory_image = "doors_item_obsidian_glass.png",
groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 }, groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 },
material = "default:obsidian_glass",
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
recipe = {
{"default:obsidian_glass", "default:obsidian_glass"},
{"default:obsidian_glass", "default:obsidian_glass"},
{"default:obsidian_glass", "default:obsidian_glass"},
},
}) })
----trapdoor---- ----trapdoor----