diff --git a/mods/bg_tree/node.lua b/mods/bg_tree/node.lua index 1a3836b..70e3077 100644 --- a/mods/bg_tree/node.lua +++ b/mods/bg_tree/node.lua @@ -1,105 +1,7 @@ local modname = minetest.get_current_modname() -local function reg_log (name, def) - def = def or {} - - def.description = def.description or "Log" - - local texture = def.texture or name - def.tiles = blockgame.underride(def.tiles, { - modname .. "_" .. texture .. "_top.png", - modname .. "_" .. texture .. "_top.png", - modname .. "_" .. texture .. ".png", - }) - - def.groups = blockgame.underride(def.groups, { - woody = 1, - supports_leaves = 1, - }) - - blockgame.register_node(modname .. ":" .. name, def) -end - -reg_log("log") -reg_log("log_alive", { - groups = { - planty = 1, - }, - texture = "log", - drop = modname .. ":log", -}) -reg_log("sapling", { - groups = { - planty = 1, - }, - drop = modname .. ":log", -}) - - - -local function leaves_fall_check (pos, node) - return blockgame.every(blockgame.vector.get_neighbors(pos), function (pos) - return minetest.get_item_group(minetest.get_node(pos).name, "supports_leaves") == 0 - end) -end - -local function reg_leaves (name, def) - def.description = def.description or name - def.texture = def.texture or name - def.tiles = {modname .. "_" .. def.texture .. ".png"} - - def.drawtype = "glasslike" - def.paramtype = "light" - def.sunlight_propagates = true - - def.groups = blockgame.underride(def.groups, { - planty = 1, - supports_leaves = 1, - air_flowable = 1, - can_fall = 1, - }) - - blockgame.register_node(modname .. ":" .. name, def) -end - -local nutty_drops = { - max_items = 3, - items = { - { - rarity = 8, - items = {modname .. ":nut"}, - }, - { - rarity = 12, - items = {modname .. ":nut 2"}, - }, - { - rarity = 1, - items = {modname .. ":leaves"}, - }, - }, -} - -reg_leaves("leaves", { - description = "Leaves", -}) -reg_leaves("leaves_growing", { - description = "Growing Leaves", - texture = "leaves_alive", - drop = nutty_drops, - fall_check = leaves_fall_check, -}) -reg_leaves("leaves_alive", { - description = "Leaves", - drop = nutty_drops, - fall_check = leaves_fall_check, -}) -reg_leaves("leaves_decomposing", { - description = "Decomposing Leaves", - groups = { - supports_leaves = 0, - }, -}) +load_file("node_log") +load_file("node_leaves") blockgame.reg_simple_node("nut", "Nut", { woody = 1, diff --git a/mods/bg_tree/node_leaves.lua b/mods/bg_tree/node_leaves.lua new file mode 100644 index 0000000..b50a917 --- /dev/null +++ b/mods/bg_tree/node_leaves.lua @@ -0,0 +1,65 @@ +local modname = minetest.get_current_modname() + +local function leaves_fall_check (pos, node) + return blockgame.every(blockgame.vector.get_neighbors(pos), function (pos) + return minetest.get_item_group(minetest.get_node(pos).name, "supports_leaves") == 0 + end) +end + +local function reg_leaves (name, def) + def.description = def.description or name + def.texture = def.texture or name + def.tiles = {modname .. "_" .. def.texture .. ".png"} + + def.drawtype = "glasslike" + def.paramtype = "light" + def.sunlight_propagates = true + + def.groups = blockgame.underride(def.groups, { + planty = 1, + supports_leaves = 1, + air_flowable = 1, + can_fall = 1, + }) + + blockgame.register_node(modname .. ":" .. name, def) +end + +local nutty_drops = { + max_items = 3, + items = { + { + rarity = 8, + items = {modname .. ":nut"}, + }, + { + rarity = 12, + items = {modname .. ":nut 2"}, + }, + { + rarity = 1, + items = {modname .. ":leaves"}, + }, + }, +} + +reg_leaves("leaves", { + description = "Leaves", +}) +reg_leaves("leaves_growing", { + description = "Growing Leaves", + texture = "leaves_alive", + drop = nutty_drops, + fall_check = leaves_fall_check, +}) +reg_leaves("leaves_alive", { + description = "Leaves", + drop = nutty_drops, + fall_check = leaves_fall_check, +}) +reg_leaves("leaves_decomposing", { + description = "Decomposing Leaves", + groups = { + supports_leaves = 0, + }, +}) diff --git a/mods/bg_tree/node_log.lua b/mods/bg_tree/node_log.lua new file mode 100644 index 0000000..1c36629 --- /dev/null +++ b/mods/bg_tree/node_log.lua @@ -0,0 +1,36 @@ +local modname = minetest.get_current_modname() + +local function reg_log (name, def) + def = def or {} + + def.description = def.description or "Log" + + local texture = def.texture or name + def.tiles = blockgame.underride(def.tiles, { + modname .. "_" .. texture .. "_top.png", + modname .. "_" .. texture .. "_top.png", + modname .. "_" .. texture .. ".png", + }) + + def.groups = blockgame.underride(def.groups, { + woody = 1, + supports_leaves = 1, + }) + + blockgame.register_node(modname .. ":" .. name, def) +end + +reg_log("log") +reg_log("log_alive", { + groups = { + planty = 1, + }, + texture = "log", + drop = modname .. ":log", +}) +reg_log("sapling", { + groups = { + planty = 1, + }, + drop = modname .. ":log", +})