mirror of
https://github.com/mt-mods/moretrees.git
synced 2024-12-24 17:50:24 +01:00
added the ability to redefine apples so that they'll fall when nearby leaves
disappear (defaults to true). Moved leafdecay code into its own file. Moved sapling configs into settings.lua
This commit is contained in:
parent
1445263d73
commit
a0af3f26de
69
init.lua
69
init.lua
@ -36,6 +36,7 @@ dofile(minetest.get_modpath("moretrees").."/node_defs.lua")
|
|||||||
dofile(minetest.get_modpath("moretrees").."/tree_models.lua")
|
dofile(minetest.get_modpath("moretrees").."/tree_models.lua")
|
||||||
dofile(minetest.get_modpath("moretrees").."/biome_defs.lua")
|
dofile(minetest.get_modpath("moretrees").."/biome_defs.lua")
|
||||||
dofile(minetest.get_modpath("moretrees").."/crafts.lua")
|
dofile(minetest.get_modpath("moretrees").."/crafts.lua")
|
||||||
|
dofile(minetest.get_modpath("moretrees").."/leafdecay.lua")
|
||||||
|
|
||||||
-- tree spawning setup
|
-- tree spawning setup
|
||||||
|
|
||||||
@ -54,9 +55,6 @@ plantslib:register_generate_plant(moretrees.fir_biome, "moretrees:grow_fir")
|
|||||||
|
|
||||||
-- sapling growth
|
-- sapling growth
|
||||||
|
|
||||||
local sapling_interval = 500
|
|
||||||
local sapling_chance = 20
|
|
||||||
|
|
||||||
for i in ipairs(moretrees.simple_trees) do
|
for i in ipairs(moretrees.simple_trees) do
|
||||||
local tree_name = trees[i][1]
|
local tree_name = trees[i][1]
|
||||||
local tree_model = tree_name.."_model"
|
local tree_model = tree_name.."_model"
|
||||||
@ -65,8 +63,8 @@ for i in ipairs(moretrees.simple_trees) do
|
|||||||
plantslib:dbg(dump(moretrees[tree_biome].surface))
|
plantslib:dbg(dump(moretrees[tree_biome].surface))
|
||||||
|
|
||||||
plantslib:grow_plants({
|
plantslib:grow_plants({
|
||||||
grow_delay = sapling_interval,
|
grow_delay = moretrees.sapling_interval,
|
||||||
grow_chance = sapling_chance,
|
grow_chance = moretrees.sapling_chance,
|
||||||
grow_plant = "moretrees:"..tree_name.."_sapling",
|
grow_plant = "moretrees:"..tree_name.."_sapling",
|
||||||
grow_nodes = moretrees[tree_biome].surface,
|
grow_nodes = moretrees[tree_biome].surface,
|
||||||
grow_function = moretrees[tree_model],
|
grow_function = moretrees[tree_model],
|
||||||
@ -74,32 +72,32 @@ for i in ipairs(moretrees.simple_trees) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
plantslib:grow_plants({
|
plantslib:grow_plants({
|
||||||
grow_delay = sapling_interval,
|
grow_delay = moretrees.sapling_interval,
|
||||||
grow_chance = sapling_chance,
|
grow_chance = moretrees.sapling_chance,
|
||||||
grow_plant = "moretrees:birch_sapling",
|
grow_plant = "moretrees:birch_sapling",
|
||||||
grow_nodes = moretrees.birch_biome.surface,
|
grow_nodes = moretrees.birch_biome.surface,
|
||||||
grow_function = "moretrees:grow_birch"
|
grow_function = "moretrees:grow_birch"
|
||||||
})
|
})
|
||||||
|
|
||||||
plantslib:grow_plants({
|
plantslib:grow_plants({
|
||||||
grow_delay = sapling_interval,
|
grow_delay = moretrees.sapling_interval,
|
||||||
grow_chance = sapling_chance,
|
grow_chance = moretrees.sapling_chance,
|
||||||
grow_plant = "moretrees:spruce_sapling",
|
grow_plant = "moretrees:spruce_sapling",
|
||||||
grow_nodes = moretrees.spruce_biome.surface,
|
grow_nodes = moretrees.spruce_biome.surface,
|
||||||
grow_function = "moretrees:grow_spruce"
|
grow_function = "moretrees:grow_spruce"
|
||||||
})
|
})
|
||||||
|
|
||||||
plantslib:grow_plants({
|
plantslib:grow_plants({
|
||||||
grow_delay = sapling_interval,
|
grow_delay = moretrees.sapling_interval,
|
||||||
grow_chance = sapling_chance,
|
grow_chance = moretrees.sapling_chance,
|
||||||
grow_plant = "moretrees:fir_sapling",
|
grow_plant = "moretrees:fir_sapling",
|
||||||
grow_nodes = moretrees.fir_biome.surface,
|
grow_nodes = moretrees.fir_biome.surface,
|
||||||
grow_function = "moretrees:grow_fir"
|
grow_function = "moretrees:grow_fir"
|
||||||
})
|
})
|
||||||
|
|
||||||
plantslib:grow_plants({
|
plantslib:grow_plants({
|
||||||
grow_delay = sapling_interval,
|
grow_delay = moretrees.sapling_interval,
|
||||||
grow_chance = sapling_chance,
|
grow_chance = moretrees.sapling_chance,
|
||||||
grow_plant = "moretrees:jungletree_sapling",
|
grow_plant = "moretrees:jungletree_sapling",
|
||||||
grow_nodes = moretrees.jungletree_biome.surface,
|
grow_nodes = moretrees.jungletree_biome.surface,
|
||||||
grow_function = "moretrees:grow_jungletree"
|
grow_function = "moretrees:grow_jungletree"
|
||||||
@ -226,49 +224,4 @@ if moretrees.firs_remove_default_trees == true then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- leaf decay
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = moretrees.leaves_list,
|
|
||||||
interval = moretrees.leafdecay_delay,
|
|
||||||
chance = moretrees.leafdecay_chance,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, moretrees.trunks_list) then
|
|
||||||
minetest.env:remove_node(pos)
|
|
||||||
minetest.env:dig_node(pos)
|
|
||||||
end
|
|
||||||
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 not minetest.env:find_node_near(pos, moretrees.palm_leafdecay_radius, moretrees.trunks_list) then
|
|
||||||
minetest.env:remove_node(pos)
|
|
||||||
minetest.env:dig_node(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if moretrees.enable_replace_default_trees then
|
|
||||||
minetest.register_alias("mapgen_tree", "air")
|
|
||||||
minetest.register_alias("mapgen_leaves", "air")
|
|
||||||
plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model)
|
|
||||||
elseif moretrees.enable_default_leafdecay then
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = "default:leaves",
|
|
||||||
interval = moretrees.default_leafdecay_delay,
|
|
||||||
chance = moretrees.default_leafdecay_chance,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
if not minetest.env:find_node_near(pos, moretrees.default_leafdecay_radius, {"default:tree"}) then
|
|
||||||
minetest.env:remove_node(pos)
|
|
||||||
minetest.env:dig_node(pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
print("[Moretrees] Loaded (2013-01-18)")
|
print("[Moretrees] Loaded (2013-01-18)")
|
||||||
|
44
leafdecay.lua
Normal file
44
leafdecay.lua
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
-- leaf decay
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = moretrees.leaves_list,
|
||||||
|
interval = moretrees.leafdecay_delay,
|
||||||
|
chance = moretrees.leafdecay_chance,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, moretrees.trunks_list) then
|
||||||
|
minetest.env:remove_node(pos)
|
||||||
|
minetest.env:dig_node(pos)
|
||||||
|
end
|
||||||
|
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 not minetest.env:find_node_near(pos, moretrees.palm_leafdecay_radius, moretrees.trunks_list) then
|
||||||
|
minetest.env:remove_node(pos)
|
||||||
|
minetest.env:dig_node(pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
if moretrees.enable_replace_default_trees then
|
||||||
|
minetest.register_alias("mapgen_tree", "air")
|
||||||
|
minetest.register_alias("mapgen_leaves", "air")
|
||||||
|
plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model)
|
||||||
|
elseif moretrees.enable_default_leafdecay then
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = "default:leaves",
|
||||||
|
interval = moretrees.default_leafdecay_delay,
|
||||||
|
chance = moretrees.default_leafdecay_chance,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
if not minetest.env:find_node_near(pos, moretrees.default_leafdecay_radius, {"default:tree"}) then
|
||||||
|
minetest.env:remove_node(pos)
|
||||||
|
minetest.env:dig_node(pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
@ -186,6 +186,27 @@ minetest.register_node("moretrees:fir_leaves_bright", {
|
|||||||
})
|
})
|
||||||
table.insert(moretrees.leaves_list, "moretrees:fir_leaves_bright")
|
table.insert(moretrees.leaves_list, "moretrees:fir_leaves_bright")
|
||||||
|
|
||||||
|
if moretrees.enable_redefine_apple then
|
||||||
|
minetest.register_node(":default:apple", {
|
||||||
|
description = "Apple",
|
||||||
|
drawtype = "plantlike",
|
||||||
|
visual_scale = 1.0,
|
||||||
|
tiles = {"default_apple.png"},
|
||||||
|
inventory_image = "default_apple.png",
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
walkable = false,
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
||||||
|
},
|
||||||
|
groups = {fleshy=3,dig_immediate=3,flammable=2,attached_node=1},
|
||||||
|
on_use = minetest.item_eat(4),
|
||||||
|
sounds = default.node_sound_defaults(),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Backward compatbility with old mods/nodes:
|
-- Backward compatbility with old mods/nodes:
|
||||||
|
|
||||||
|
@ -12,6 +12,11 @@ moretrees.enable_replace_default_trees = false
|
|||||||
|
|
||||||
moretrees.enable_default_leafdecay = false
|
moretrees.enable_default_leafdecay = false
|
||||||
|
|
||||||
|
-- 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 in general.
|
-- various settings to configure leaf decay in general.
|
||||||
|
|
||||||
moretrees.leafdecay_delay = 2
|
moretrees.leafdecay_delay = 2
|
||||||
@ -31,3 +36,7 @@ moretrees.firs_remove_default_trees = false
|
|||||||
moretrees.firs_remove_interval = 2
|
moretrees.firs_remove_interval = 2
|
||||||
moretrees.firs_remove_chance = 150
|
moretrees.firs_remove_chance = 150
|
||||||
|
|
||||||
|
-- Sapling settings
|
||||||
|
|
||||||
|
moretrees.sapling_interval = 500
|
||||||
|
moretrees.sapling_chance = 20
|
||||||
|
Loading…
Reference in New Issue
Block a user