From 47b32ecae10a0d1bedaaef9efdf1d3e4639e8060 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 25 Aug 2019 16:02:25 +0200 Subject: [PATCH] Simplify trap stone definition --- nodes.lua | 99 +++++++++++++++++++------------------------------------ 1 file changed, 33 insertions(+), 66 deletions(-) diff --git a/nodes.lua b/nodes.lua index f31e3c3..6c3cb0f 100644 --- a/nodes.lua +++ b/nodes.lua @@ -61,72 +61,39 @@ local trap_on_timer = function(pos, elapsed) return true end -minetest.register_node("tsm_pyramids:trap", { - description = S("Cracked Sandstone Brick"), - _doc_items_longdesc = S("This brick is old, porous and unstable and is barely able to hold itself. One should be careful not to disturb it."), - tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png"}, - is_ground_content = false, - groups = {crumbly=3,cracky=3}, - sounds = default.node_sound_stone_defaults(), - on_construct = function(pos) - minetest.get_node_timer(pos):start(0.1) - end, - _tsm_pyramids_crack = 1, - on_timer = trap_on_timer, - drop = { - items = { - { items = { "default:sand" }, rarity = 1 }, - { items = { "default:sand" }, rarity = 2 }, - }, - } -}) +local register_trap_stone = function(basename, desc_normal, desc_falling, base_tile, drop) + minetest.register_node("tsm_pyramids:"..basename, { + description = desc_normal, + _doc_items_longdesc = S("This brick is old, porous and unstable and is barely able to hold itself. One should be careful not to disturb it."), + tiles = { base_tile .. "^tsm_pyramids_crack.png" }, + is_ground_content = false, + groups = {crumbly=3,cracky=3}, + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + minetest.get_node_timer(pos):start(0.1) + end, + _tsm_pyramids_crack = 1, + on_timer = trap_on_timer, + drop = drop, + }) -minetest.register_node("tsm_pyramids:trap_2", { - description = S("Falling Cracked Sandstone Brick"), - _doc_items_longdesc = S("This old porous brick falls under its own weight."), - tiles = {"default_sandstone_brick.png^tsm_pyramids_crack2.png"}, - is_ground_content = false, - groups = {crumbly=3,cracky=3,falling_node=1,not_in_creative_inventory=1}, - sounds = default.node_sound_stone_defaults(), - drop = { - items = { - { items = { "default:sand" }, rarity = 1 }, - { items = { "default:sand" }, rarity = 2 }, - }, - } -}) + minetest.register_node("tsm_pyramids:"..basename.."_2", { + description = desc_falling, + _doc_items_longdesc = S("This old porous brick falls under its own weight."), + tiles = { base_tile .. "^tsm_pyramids_crack2.png" }, + is_ground_content = false, + groups = {crumbly=3,cracky=3,falling_node=1,not_in_creative_inventory=1}, + sounds = default.node_sound_stone_defaults(), + drop = drop, + }) +end -minetest.register_node("tsm_pyramids:desert_trap", { - description = S("Cracked Desert Sandstone Brick"), - _doc_items_longdesc = S("This brick is old, porous and unstable and is barely able to hold itself. One should be careful not to disturb it."), - tiles = {"default_desert_sandstone_brick.png^tsm_pyramids_crack.png"}, - is_ground_content = false, - groups = {crumbly=3,cracky=3}, - sounds = default.node_sound_stone_defaults(), - on_construct = function(pos) - minetest.get_node_timer(pos):start(0.1) - end, - _tsm_pyramids_crack = 1, - on_timer = trap_on_timer, - drop = { - items = { - { items = { "default:desert_sand" }, rarity = 1 }, - { items = { "default:desert_sand" }, rarity = 2 }, - }, - } -}) +register_trap_stone("trap", + S("Cracked Sandstone Brick"), S("Falling Cracked Sandstone Brick"), + "default_sandstone_brick.png", + { items = { { items = { "default:sand" }, rarity = 1 }, { items = { "default:sand" }, rarity = 2 }, } }) +register_trap_stone("desert_trap", + S("Cracked Desert Sandstone Brick"), S("Falling Cracked Desert Sandstone Brick"), + "default_desert_sandstone_brick.png", + { items = { { items = { "default:desert_sand" }, rarity = 1 }, { items = { "default:desert_sand" }, rarity = 2 }, } }) -minetest.register_node("tsm_pyramids:desert_trap_2", { - description = S("Falling Cracked Desert Sandstone Brick"), - _doc_items_longdesc = S("This old porous brick falls under its own weight."), - tiles = {"default_desert_sandstone_brick.png^tsm_pyramids_crack2.png"}, - is_ground_content = false, - groups = {crumbly=3,cracky=3,falling_node=1,not_in_creative_inventory=1}, - sounds = default.node_sound_stone_defaults(), - drop = { - items = { - { items = { "default:desert_sand" }, rarity = 1 }, - { items = { "default:desert_sand" }, rarity = 2 }, - }, - } -})