mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2024-12-25 01:50:20 +01:00
Vines: Simplifying digging logic.
This commit is contained in:
parent
93265656cc
commit
54d3b669be
@ -37,35 +37,28 @@ end
|
|||||||
-- FUNCTIONS
|
-- FUNCTIONS
|
||||||
|
|
||||||
local function on_dig(pos, node, player)
|
local function on_dig(pos, node, player)
|
||||||
wielded_item = player:get_wielded_item()
|
vine_name_end = node.name:gsub("_middle", "_end")
|
||||||
if wielded_item and wielded_item:get_name() == 'vines:shears' then
|
drop_item = "vines:vines"
|
||||||
wielded_item:add_wear(1)
|
if enable_vines == false then
|
||||||
|
drop_item = vine_name_end
|
||||||
vine_name_end = node.name:gsub("_middle", "_end")
|
end
|
||||||
minetest.remove_node(pos)
|
|
||||||
minetest.handle_node_drops(pos, {vine_name_end}, player)
|
wielded_item = player:get_wielded_item()
|
||||||
|
if wielded_item then
|
||||||
below_pos = {x = pos.x, y = pos.y - 1, z = pos.z}
|
wielded_item:add_wear(1)
|
||||||
while minetest.get_item_group(minetest.get_node(below_pos).name, "vines") > 0 do
|
if wielded_item:get_name() == 'vines:shears' then
|
||||||
minetest.remove_node(below_pos)
|
drop_item = vine_name_end
|
||||||
minetest.handle_node_drops(below_pos, {vine_name_end}, player)
|
end
|
||||||
below_pos.y = below_pos.y - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
minetest.node_dig(pos, node, player)
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local function dig_down(pos, node, digger)
|
minetest.remove_node(pos)
|
||||||
|
minetest.handle_node_drops(pos, {drop_item}, player)
|
||||||
|
|
||||||
if digger == nil then return end
|
below_pos = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||||
|
while minetest.get_item_group(minetest.get_node(below_pos).name, "vines") > 0 do
|
||||||
local np = {x = pos.x, y = pos.y - 1, z = pos.z}
|
minetest.remove_node(below_pos)
|
||||||
local nn = minetest.get_node(np)
|
minetest.handle_node_drops(below_pos, {drop_item}, player)
|
||||||
|
below_pos.y = below_pos.y - 1
|
||||||
if minetest.get_item_group(nn.name, "vines") > 0 then
|
|
||||||
minetest.node_dig(np, nn, digger)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -90,11 +83,6 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
local vine_image_end = "vines_" .. name .. "_end.png"
|
local vine_image_end = "vines_" .. name .. "_end.png"
|
||||||
local vine_image_middle = "vines_" .. name .. "_middle.png"
|
local vine_image_middle = "vines_" .. name .. "_middle.png"
|
||||||
|
|
||||||
local drop_node = vine_name_end
|
|
||||||
if enable_vines ~= false then
|
|
||||||
drop_node = "vines:vines"
|
|
||||||
end
|
|
||||||
|
|
||||||
local spawn_plants = function(pos, fdir)
|
local spawn_plants = function(pos, fdir)
|
||||||
local max_length = math.random(defs.average_length)
|
local max_length = math.random(defs.average_length)
|
||||||
local current_length = 0
|
local current_length = 0
|
||||||
@ -128,7 +116,7 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
walkable = false,
|
walkable = false,
|
||||||
climbable = true,
|
climbable = true,
|
||||||
wield_image = vine_image_end,
|
wield_image = vine_image_end,
|
||||||
drop = drop_node,
|
drop = {},
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
@ -170,10 +158,6 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
|
|
||||||
on_dig = on_dig,
|
on_dig = on_dig,
|
||||||
|
|
||||||
after_dig_node = function(pos, node, metadata, digger)
|
|
||||||
dig_down(pos, node, digger)
|
|
||||||
end,
|
|
||||||
|
|
||||||
after_destruct = function(pos, oldnode)
|
after_destruct = function(pos, oldnode)
|
||||||
ensure_vine_end(pos, oldnode)
|
ensure_vine_end(pos, oldnode)
|
||||||
end,
|
end,
|
||||||
@ -183,7 +167,7 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
description = S("Matured") .. " " .. defs.description,
|
description = S("Matured") .. " " .. defs.description,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
climbable = true,
|
climbable = true,
|
||||||
drop = drop_node,
|
drop = {},
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
@ -198,10 +182,6 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
|
|
||||||
on_dig = on_dig,
|
on_dig = on_dig,
|
||||||
|
|
||||||
after_dig_node = function(pos, node, metadata, digger)
|
|
||||||
dig_down(pos, node, digger)
|
|
||||||
end,
|
|
||||||
|
|
||||||
after_destruct = function(pos, oldnode)
|
after_destruct = function(pos, oldnode)
|
||||||
ensure_vine_end(pos, oldnode)
|
ensure_vine_end(pos, oldnode)
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user