diff --git a/mods/stairs/init.lua b/mods/stairs/init.lua index 7f84b4c0..fd69dcbf 100644 --- a/mods/stairs/init.lua +++ b/mods/stairs/init.lua @@ -3,18 +3,19 @@ stairs = {} +local recipeitem_things = {"tiles","use_texture_alpha","alpha","light_source","sounds","groups"} + -- Node will be called stairs:stair_ -function stairs.register_stair(subname, recipeitem, groups, images, description, sounds) - minetest.register_node(":stairs:stair_" .. subname, { - description = description, +function stairs.register_stair(subname, recipeitem, groups_or_def, images, description, sounds) + local recipe_def = table.copy(minetest.registered_nodes[recipeitem]) or {} + local node_def = { + description = recipe_def.description.." Stair", + is_ground_content = false, drawtype = "mesh", mesh = "stairs_stair.obj", - tiles = images, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, - groups = groups, - sounds = sounds, selection_box = { type = "fixed", fixed = { @@ -59,7 +60,25 @@ function stairs.register_stair(subname, recipeitem, groups, images, description, return minetest.item_place(itemstack, placer, pointed_thing, param2) end, - }) + } + + for _,i in ipairs(recipeitem_things) do + node_def[i] = recipe_def[i] or node_def[i] + end + + if not images and groups_or_def then + for n,i in pairs(groups_or_def) do + node_def[n] = i + end + else + node_def.groups = groups_or_def or node_def.groups + end + + node_def.tiles = images or node_def.tiles + node_def.sounds = sounds or node_def.sounds + node_def.description = description or node_def.description + + minetest.register_node(":stairs:stair_" .. subname, node_def) -- for replace ABM minetest.register_node(":stairs:stair_" .. subname.."upside_down", { @@ -88,16 +107,14 @@ function stairs.register_stair(subname, recipeitem, groups, images, description, end -- Node will be called stairs:slab_ -function stairs.register_slab(subname, recipeitem, groups, images, description, sounds) - minetest.register_node(":stairs:slab_" .. subname, { - description = description, +function stairs.register_slab(subname, recipeitem, groups_or_def, images, description, sounds) + local recipe_def = table.copy(minetest.registered_nodes[recipeitem]) or {} + local node_def = { + description = recipe_def.description.." Slab", drawtype = "nodebox", - tiles = images, paramtype = "light", paramtype2 = "facedir", is_ground_content = false, - groups = groups, - sounds = sounds, node_box = { type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, @@ -180,8 +197,26 @@ function stairs.register_slab(subname, recipeitem, groups, images, description, end return minetest.item_place(itemstack, placer, pointed_thing, param2) - end, - }) + end + } + + for _,i in ipairs(recipeitem_things) do + node_def[i] = recipe_def[i] or node_def[i] + end + + if not images and groups_or_def then + for n,i in pairs(groups_or_def) do + node_def[n] = i + end + else + node_def.groups = groups_or_def or node_def.groups + end + + node_def.tiles = images or node_def.tiles + node_def.sounds = sounds or node_def.sounds + node_def.description = description or node_def.description + + minetest.register_node(":stairs:slab_" .. subname, node_def) -- for replace ABM minetest.register_node(":stairs:slab_" .. subname.."upside_down", { @@ -215,105 +250,51 @@ minetest.register_abm({ }) -- Nodes will be called stairs:{stair,slab}_ -function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds) - stairs.register_stair(subname, recipeitem, groups, images, desc_stair, sounds) - stairs.register_slab(subname, recipeitem, groups, images, desc_slab, sounds) +function stairs.register_stair_and_slab(subname, recipeitem, groups_or_def, images, desc_stair, desc_slab, sounds) + stairs.register_stair(subname, recipeitem, groups_or_def, images, desc_stair, sounds) + stairs.register_slab(subname, recipeitem, groups_or_def, images, desc_slab, sounds) end stairs.register_stair_and_slab("wood", "default:wood", {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}, {"default_wood.png"}, "Wooden Stair", - "Wooden Slab", - default.node_sound_wood_defaults()) - -stairs.register_stair_and_slab("stone", "default:stone", - {cracky=3}, - {"default_stone.png"}, - "Stone Stair", - "Stone Slab", - default.node_sound_stone_defaults()) - -stairs.register_stair_and_slab("cobble", "default:cobble", - {cracky=3}, - {"default_cobble.png"}, - "Cobblestone Stair", - "Cobblestone Slab", - default.node_sound_stone_defaults()) - -stairs.register_stair_and_slab("desert_stone", "default:desert_stone", - {cracky=3}, - {"default_desert_stone.png"}, - "Desertstone Stair", - "Desertstone Slab", - default.node_sound_stone_defaults()) - -stairs.register_stair_and_slab("desert_cobble", "default:desert_cobble", - {cracky=3}, - {"default_desert_cobble.png"}, - "Desert Cobblestone Stair", - "Desert Cobblestone Slab", - default.node_sound_stone_defaults()) - -stairs.register_stair_and_slab("desert_stonebrick", "default:desert_stonebrick", - {cracky=3}, - {"default_desert_stone_brick.png"}, - "Desert Stone Brick Stair", - "Desert Stone Brick Slab", - default.node_sound_stone_defaults()) - -stairs.register_stair_and_slab("brick", "default:brick", - {cracky=3}, - {"default_brick.png"}, - "Brick Stair", - "Brick Slab", - default.node_sound_stone_defaults()) - -stairs.register_stair_and_slab("sandstone", "default:sandstone", - {crumbly=2,cracky=2}, - {"default_sandstone.png"}, - "Sandstone Stair", - "Sandstone Slab", - default.node_sound_stone_defaults()) - -stairs.register_stair_and_slab("sandstonebrick", "default:sandstonebrick", - {crumbly=2,cracky=2}, - {"default_sandstone_brick.png"}, - "Sandstone Brick Stair", - "Sandstone Brick Slab", - default.node_sound_stone_defaults()) + "Wooden Slab") stairs.register_stair_and_slab("junglewood", "default:junglewood", {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}, {"default_junglewood.png"}, "Junglewood Stair", - "Junglewood Slab", - default.node_sound_wood_defaults()) - -stairs.register_stair_and_slab("stonebrick", "default:stonebrick", - {cracky=3}, - {"default_stone_brick.png"}, - "Stone Brick Stair", - "Stone Brick Slab", - default.node_sound_stone_defaults()) + "Junglewood Slab") stairs.register_stair_and_slab("pinewood", "default:pinewood", {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}, {"default_pinewood.png"}, "Pinewood Stair", - "Pinewood Slab", - default.node_sound_wood_defaults()) + "Pinewood Slab") -stairs.register_stair_and_slab("obsidian", "default:obsidian", - {cracky=1,level=2}, - {"default_obsidian.png"}, - "Obsidian Stair", - "Obsidian Slab", - default.node_sound_stone_defaults()) +stairs.register_stair_and_slab("brick", "default:brick", + {cracky=3}, + {"default_brick.png"}, + "Brick Stair", + "Brick Slab") -stairs.register_stair_and_slab("obsidianbrick", "default:obsidianbrick", - {cracky=1,level=2}, - {"default_obsidian_brick.png"}, - "Obsidian Brick Stair", - "Obsidian Brick Slab", - default.node_sound_stone_defaults()) +stairs.register_stair_and_slab("stone", "default:stone") + +stairs.register_stair_and_slab("cobble", "default:cobble") + +stairs.register_stair_and_slab("desert_stone", "default:desert_stone") + +stairs.register_stair_and_slab("desert_cobble", "default:desert_cobble") + +stairs.register_stair_and_slab("desert_stonebrick", "default:desert_stonebrick") + +stairs.register_stair_and_slab("sandstone", "default:sandstone") + +stairs.register_stair_and_slab("stonebrick", "default:stonebrick") + +stairs.register_stair_and_slab("sandstonebrick", "default:sandstonebrick") + +stairs.register_stair_and_slab("obsidian", "default:obsidian") + +stairs.register_stair_and_slab("obsidianbrick", "default:obsidianbrick")