Skip to content

Commit

Permalink
Doors: Allow arbitrary recipe to be passed, even nil
Browse files Browse the repository at this point in the history
This allows mod makers to register their own recipies, including
none, to register doors.
  • Loading branch information
sofar authored and paramat committed Feb 18, 2016
1 parent 8422f2e commit 363b95c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion game_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ doors.get(pos)
inventory_image = "mod_door_inv.png",
groups = {choppy = 1},
tiles = { "mod_door.png" },
material = "default:wood", -- used to make a craft recipe
recipe = craftrecipe,
sounds = default.node_sound_wood_defaults(), -- optional
sound_open = sound play for open door, -- optional
sound_close = sound play for close door, -- optional
Expand Down
38 changes: 26 additions & 12 deletions mods/doors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,12 @@ function doors.register(name, def)
},
})

minetest.register_craft({
output = "doors:" .. name,
recipe = {
{def.material,def.material};
{def.material,def.material};
{def.material,def.material};
}
})
if def.recipe then
minetest.register_craft({
output = "doors:" .. name,
recipe = def.recipe,
})
end

_doors.registered_doors["doors:" .. name .. "_a"] = true
_doors.registered_doors["doors:" .. name .. "_b"] = true
Expand All @@ -370,7 +368,11 @@ doors.register("door_wood", {
description = "Wooden Door",
inventory_image = "doors_item_wood.png",
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", {
Expand All @@ -379,25 +381,37 @@ doors.register("door_steel", {
inventory_image = "doors_item_steel.png",
protected = true,
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", {
tiles = { "doors_door_glass.png"},
description = "Glass Door",
inventory_image = "doors_item_glass.png",
groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 },
material = "default:glass",
sounds = default.node_sound_glass_defaults(),
recipe = {
{"default:glass", "default:glass"},
{"default:glass", "default:glass"},
{"default:glass", "default:glass"},
}
})

doors.register("door_obsidian_glass", {
tiles = { "doors_door_obsidian_glass.png" },
description = "Glass Door",
inventory_image = "doors_item_obsidian_glass.png",
groups = { snappy=1, cracky=1, oddly_breakable_by_hand=3 },
material = "default:obsidian_glass",
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----
Expand Down

0 comments on commit 363b95c

Please sign in to comment.