From 35f560c9190e44d7bd54bfba4699be1eaaa1af38 Mon Sep 17 00:00:00 2001 From: MoNTE48 Date: Fri, 20 Dec 2019 21:18:08 +0100 Subject: [PATCH] Vine: add spreading and fuel recipe --- files/default/crafting.lua | 6 ++++++ files/default/functions.lua | 13 +++++++++++++ files/default/nodes.lua | 36 +++++++++++++++++++++++------------- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/files/default/crafting.lua b/files/default/crafting.lua index f5fcbcc..ecdf70c 100644 --- a/files/default/crafting.lua +++ b/files/default/crafting.lua @@ -473,6 +473,12 @@ minetest.register_craft({ burntime = 5 }) +minetest.register_craft({ + type = "fuel", + recipe = "default:vine", + burntime = 3 +}) + minetest.register_craft({ type = "fuel", recipe = "bucket:bucket_lava", diff --git a/files/default/functions.lua b/files/default/functions.lua index 61e5efb..870637d 100644 --- a/files/default/functions.lua +++ b/files/default/functions.lua @@ -296,6 +296,19 @@ function default.dig_up(pos, node, digger) end end +-- +-- Dig downwards +-- + +function default.dig_down(pos, node, digger) + if digger == nil then return end + local np = {x = pos.x, y = pos.y - 1, z = pos.z} + local nn = minetest.get_node(np) + if nn.name == node.name then + minetest.node_dig(np, nn, digger) + end +end + -- -- Fence registration helper diff --git a/files/default/nodes.lua b/files/default/nodes.lua index b9b08fd..c7f03c1 100644 --- a/files/default/nodes.lua +++ b/files/default/nodes.lua @@ -952,7 +952,6 @@ minetest.register_node("default:grass", { sounds = default.node_sound_leaves_defaults() }) - minetest.register_node("default:dry_grass", { description = "Dry Grass", drawtype = "plantlike", @@ -1461,18 +1460,29 @@ minetest.register_node("default:vine", { }, groups = {choppy = 2, oddly_breakable_by_hand = 3, flammable = 2}, sounds = default.node_sound_leaves_defaults(), - after_dig_node = function(pos) - local next_find = true - local down = 1 - while next_find do - pos.y = pos.y - down - local node = minetest.get_node(pos) - if node.name == "default:vine" then - minetest.remove_node(pos) - down = down + 1 - else - next_find = false - end + + on_construct = function(pos) + minetest.get_node_timer(pos):start(math.random(30, 60)) + end, + + on_timer = function(pos) + local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z} + if (minetest.get_node_light(pos) or 0) < 13 then + return true + end + if minetest.get_node(pos_under).name == "air" then + minetest.set_node(pos_under, { + name = "default:vine", + param2 = minetest.get_node(pos).param2 + }) + end + end, + + after_dig_node = function(pos, node, _, digger) + default.dig_down(pos, node, digger) + local pos_above = {x = pos.x, y = pos.y + 1, z = pos.z} + if minetest.get_node(pos_above).name == "default:vine" then + minetest.get_node_timer(pos_above):start(math.random(30, 60)) end end })