mirror of
https://github.com/mt-mods/moretrees.git
synced 2024-12-26 10:40:24 +01:00
use default leaf decay code for everything.
This commit is contained in:
parent
6694b8da61
commit
f59fd56257
@ -34,26 +34,21 @@ moretrees.enable_stairs = true
|
||||
|
||||
moretrees.plantlike_leaves = false
|
||||
|
||||
-- Set this to true to enable leaf decay of all trees except the default ones.
|
||||
|
||||
moretrees.enable_leafdecay = true
|
||||
|
||||
-- Enable this if you want moretrees to redefine default apples so that they
|
||||
-- fall when leaves decay/are dug.
|
||||
|
||||
moretrees.enable_redefine_apple = true
|
||||
|
||||
-- various settings to configure leaf decay.
|
||||
-- Set this to true to enable leaf decay of all trees except the default ones.
|
||||
|
||||
moretrees.enable_leafdecay = true
|
||||
|
||||
-- various related settings to configure leaf decay.
|
||||
|
||||
moretrees.leafdecay_delay = 2
|
||||
moretrees.leafdecay_chance = 100
|
||||
moretrees.leafdecay_chance = 5
|
||||
moretrees.leafdecay_radius = 5
|
||||
|
||||
moretrees.palm_leafdecay_radius = 15
|
||||
|
||||
moretrees.default_leafdecay_delay = 3
|
||||
moretrees.default_leafdecay_chance = 50
|
||||
moretrees.default_leafdecay_radius = 4
|
||||
moretrees.palm_leafdecay_radius = 10
|
||||
|
||||
-- Change these settings if you want default trees to be gradually cut down
|
||||
-- above the elevation where firs normally generate.
|
||||
|
1
init.lua
1
init.lua
@ -89,7 +89,6 @@ dofile(modpath.."/node_defs.lua")
|
||||
dofile(modpath.."/biome_defs.lua")
|
||||
dofile(modpath.."/saplings.lua")
|
||||
dofile(modpath.."/crafts.lua")
|
||||
dofile(modpath.."/leafdecay.lua")
|
||||
|
||||
-- tree spawning setup
|
||||
|
||||
|
@ -1,87 +0,0 @@
|
||||
-- leaf decay
|
||||
|
||||
-- this function is based on the default leafdecay code
|
||||
local process_drops = function(pos, name)
|
||||
local drops = minetest.get_node_drops(name)
|
||||
for _,dropitem in ipairs(drops) do
|
||||
if dropitem ~= name
|
||||
or (string.find(name, "leaves") and moretrees.decay_leaves_as_items) then
|
||||
local newpos = {
|
||||
x=pos.x + math.random() - 0.5,
|
||||
y=pos.y + math.random() - 0.5,
|
||||
z=pos.z + math.random() - 0.5
|
||||
}
|
||||
minetest.add_item(newpos, dropitem)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if moretrees.enable_leafdecay then
|
||||
for i in ipairs(moretrees.treelist) do
|
||||
local treename = moretrees.treelist[i][1]
|
||||
if treename ~= "jungletree" and treename ~= "pine" and treename ~= "acacia" and treename ~= "fir" and treename ~= "palm" then
|
||||
minetest.register_abm({
|
||||
nodenames = "moretrees:"..treename.."_leaves",
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.find_node_near(pos, moretrees.leafdecay_radius, { "ignore", "moretrees:"..treename.."_trunk" }) then return end
|
||||
process_drops(pos, node.name)
|
||||
minetest.remove_node(pos)
|
||||
nodeupdate(pos)
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:jungleleaves", "moretrees:jungletree_leaves_red", "moretrees:jungletree_leaves_yellow"},
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.find_node_near(pos, moretrees.leafdecay_radius, {"ignore", "default:jungletree"}) then return end
|
||||
process_drops(pos, node.name)
|
||||
minetest.remove_node(pos)
|
||||
nodeupdate(pos)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"moretrees:fir_leaves", "moretrees:fir_leaves_bright"},
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.find_node_near(pos, moretrees.leafdecay_radius, { "ignore", "moretrees:fir_trunk" }) then return end
|
||||
process_drops(pos, node.name)
|
||||
minetest.remove_node(pos)
|
||||
nodeupdate(pos)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = "moretrees:palm_leaves",
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.find_node_near(pos, moretrees.palm_leafdecay_radius, { "ignore", "moretrees:palm_trunk" }) then return end
|
||||
process_drops(pos, node.name)
|
||||
minetest.remove_node(pos)
|
||||
nodeupdate(pos)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
-- Decay apple tree blossoms from nature_classic mod
|
||||
if minetest.get_modpath("nature_classic") then
|
||||
minetest.register_abm({
|
||||
nodenames = "moretrees:apple_blossoms",
|
||||
interval = moretrees.default_leafdecay_delay,
|
||||
chance = moretrees.default_leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.find_node_near(pos, moretrees.leafdecay_radius, { "ignore", "moretrees:apple_tree_trunk" }) then return end
|
||||
process_drops(pos, "moretrees:apple_tree_leaves")
|
||||
minetest.remove_node(pos)
|
||||
nodeupdate(pos)
|
||||
end
|
||||
})
|
||||
end
|
@ -33,11 +33,6 @@ end
|
||||
|
||||
-- redefine default leaves to handle plantlike and/or leaf decay options
|
||||
|
||||
if moretrees.enable_default_leafdecay then
|
||||
minetest.override_item("default:leaves", {
|
||||
groups = { snappy = 3, flammable = 2, leaves = 1 }
|
||||
})
|
||||
end
|
||||
if moretrees.plantlike_leaves then
|
||||
minetest.override_item("default:leaves", {
|
||||
inventory_image = minetest.inventorycube("default_leaves.png"),
|
||||
@ -52,11 +47,6 @@ end
|
||||
|
||||
-- redefine default jungle leaves for same
|
||||
|
||||
if moretrees.enable_default_leafdecay then
|
||||
minetest.override_item("default:jungleleaves", {
|
||||
groups = { snappy = 3, flammable = 2, leaves = 1 }
|
||||
})
|
||||
end
|
||||
if moretrees.plantlike_leaves then
|
||||
minetest.override_item("default:jungleleaves", {
|
||||
inventory_image = minetest.inventorycube("default_jungleleaves.png"),
|
||||
@ -125,9 +115,11 @@ for i in ipairs(moretrees.treelist) do
|
||||
-- this is because max_items is 1
|
||||
|
||||
local droprarity = 100
|
||||
local decay = moretrees.leafdecay_radius
|
||||
|
||||
if treename == "palm" then
|
||||
droprarity = 20
|
||||
decay = moretrees.palm_leafdecay_radius
|
||||
end
|
||||
|
||||
local moretrees_leaves_inventory_image = nil
|
||||
@ -147,7 +139,7 @@ for i in ipairs(moretrees.treelist) do
|
||||
tiles = { "moretrees_"..treename.."_leaves.png" },
|
||||
inventory_image = moretrees_leaves_inventory_image,
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, flammable=2, leaves=1, moretrees_leaves=1},
|
||||
groups = {snappy = 3, flammable = 2, leaves = 1, moretrees_leaves = 1, leafdecay = decay},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
||||
drop = {
|
||||
@ -298,7 +290,7 @@ for color = 1, #jungleleaves do
|
||||
tiles = {"moretrees_jungletree_leaves_"..jungleleaves[color]..".png"},
|
||||
inventory_image = moretrees_leaves_inventory_image,
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, flammable=2, leaves=1, moretrees_leaves=1},
|
||||
groups = {snappy = 3, flammable = 2, leaves = 1, moretrees_leaves = 1, leafdecay = 3 },
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
@ -326,7 +318,7 @@ minetest.register_node("moretrees:fir_leaves_bright", {
|
||||
tiles = { "moretrees_fir_leaves_bright.png" },
|
||||
inventory_image = moretrees_leaves_inventory_image,
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, flammable=2, leaves=1, moretrees_leaves=1 },
|
||||
groups = {snappy = 3, flammable = 2, leaves = 1, moretrees_leaves = 1, leafdecay = 3 },
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
|
Loading…
Reference in New Issue
Block a user