From 06110f157b013688dcaec14a11170d1c143b9ffb Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Mon, 16 Oct 2023 20:32:52 +0200 Subject: [PATCH] refactor leaves node registrations. --- mods/bg_tree/node.lua | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/mods/bg_tree/node.lua b/mods/bg_tree/node.lua index 0a82470..e3ef4e3 100644 --- a/mods/bg_tree/node.lua +++ b/mods/bg_tree/node.lua @@ -29,31 +29,26 @@ blockgame.reg_simple_node("sapling", "Sapling", { planty = 1, }) -blockgame.register_node(modname .. ":leaves", { - description = "Leaves", - drawtype = "glasslike", - tiles = { - modname .. "_leaves.png", - }, - paramtype = "light", - sunlight_propagates = true, - groups = { - planty = 1, - }, -}) -blockgame.register_node(modname .. ":leaves_alive", { - description = "Growing Leaves", - drawtype = "glasslike", - tiles = { - modname .. "_leaves_alive.png", - }, - paramtype = "light", - sunlight_propagates = true, - groups = { - planty = 1, - }, - drop = modname .. ":leaves", +local function reg_leaves (name, desc, groups, drop) + blockgame.register_node(modname .. ":" .. name, { + description = desc, + drawtype = "glasslike", + tiles = { + modname .. "_" .. name .. ".png", + }, + paramtype = "light", + sunlight_propagates = true, + groups = groups, + drop = drop, + }) +end + +reg_leaves("leaves", "Leaves", { + planty = 1, }) +reg_leaves("leaves_alive", "Growing Leaves", { + planty = 1, +}, modname .. ":leaves") blockgame.reg_simple_node("nut", "Nut", { woody = 1,