Simplify wall registration

This commit is contained in:
Wuzzy 2018-12-03 17:30:09 +01:00
parent 6fdf57d44f
commit 367469cf90
2 changed files with 25 additions and 19 deletions

View file

@ -86,13 +86,13 @@ local full_blocks = {
--[[ Adds a new wall type.
* nodename: Itemstring of base node to add. Must not contain an underscore
* description: Item description (tooltip), visible to user
* craft_material: Material for the default crafting recipe (optional)
* source: Source block to craft this thing, for graphics, tiles and crafting (optional)
* tiles: Wall textures table
* inventory_image: Inventory image (optional)
* groups: Base group memberships (optional, default is {pickaxey=1})
* sounds: Sound table (optional, default is stone)
]]
function mcl_walls.register_wall(nodename, description, craft_material, tiles, inventory_image, groups, sounds)
function mcl_walls.register_wall(nodename, description, source, tiles, inventory_image, groups, sounds)
local base_groups = groups
if not base_groups then
@ -112,6 +112,12 @@ function mcl_walls.register_wall(nodename, description, craft_material, tiles, i
sounds = mcl_sounds.node_sound_stone_defaults()
end
if (not tiles) and source then
if minetest.registered_nodes[source] then
tiles = minetest.registered_nodes[source].tiles
end
end
for i = 0, 15 do
local need = {}
local need_pillar = false
@ -242,12 +248,12 @@ function mcl_walls.register_wall(nodename, description, craft_material, tiles, i
_mcl_blast_resistance = 30,
_mcl_hardness = 2,
})
if craft_material then
if source then
minetest.register_craft({
output = nodename .. " 6",
recipe = {
{craft_material, craft_material, craft_material},
{craft_material, craft_material, craft_material},
{source, source, source},
{source, source, source},
}
})
end