1
0
mirror of https://github.com/mt-mods/moretrees.git synced 2024-11-15 23:10:20 +01:00

make fast growth saplings work

This commit is contained in:
unknown 2022-07-01 15:14:09 -04:00
parent 12bcdfe57b
commit debe6a852b
4 changed files with 35 additions and 49 deletions

View File

@ -32,7 +32,7 @@ ftrunk.after_destruct = function(pos, oldnode)
-- minetest.dig_node(coconutpos) does not cause nearby coconuts to be dropped :-( ...
--minetest.dig_node(coconutpos)
local items = minetest.get_node_drops(minetest.get_node(coconutpos).name)
minetest.swap_node(coconutpos, biome_lib.air)
minetest.swap_node(coconutpos, {name = "air"})
for _, itemname in pairs(items) do
minetest.add_item(coconutpos, itemname)
end
@ -127,7 +127,7 @@ local coconut_growfn = function(pos, elapsed)
minetest.add_item(pos, itemname)
end
end
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
end
else
-- Grow coconuts to the next stage

View File

@ -52,7 +52,7 @@ ftrunk.after_destruct = function(pos, oldnode)
for _,datespos in pairs(dates) do
-- minetest.dig_node(datespos) does not cause nearby dates to be dropped :-( ...
local items = minetest.get_node_drops(minetest.get_node(datespos).name)
minetest.swap_node(datespos, biome_lib.air)
minetest.swap_node(datespos, {name = "air"})
for _, itemname in pairs(items) do
minetest.add_item(datespos, itemname)
end
@ -547,7 +547,7 @@ local dates_growfn = function(pos, elapsed)
elseif string.find(node.name, "moretrees:dates_m") then
minetest.swap_node(pos, {name="moretrees:dates_n"})
else
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
end
return
elseif node.name == "moretrees:dates_f0" and math.random(100) <= 100 * dates_regrow_prob then
@ -587,7 +587,7 @@ local dates_growfn = function(pos, elapsed)
elseif string.match(node.name, "n$") then
-- Remove stems.
if math.random(stems_drop_ichance) == 1 then
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
return "stemdrop"
end
action = "nostemdrop"

View File

@ -95,42 +95,22 @@ dofile(modpath.."/saplings.lua")
dofile(modpath.."/crafts.lua")
-- tree spawning setup
if moretrees.spawn_saplings then
moretrees.spawn_beech_object = "moretrees:beech_sapling_ongen"
moretrees.spawn_apple_tree_object = "moretrees:apple_tree_sapling_ongen"
moretrees.spawn_oak_object = "moretrees:oak_sapling_ongen"
moretrees.spawn_sequoia_object = "moretrees:sequoia_sapling_ongen"
moretrees.spawn_palm_object = "moretrees:palm_sapling_ongen"
moretrees.spawn_date_palm_object = "moretrees:date_palm_sapling_ongen"
moretrees.spawn_cedar_object = "moretrees:cedar_sapling_ongen"
moretrees.spawn_rubber_tree_object = "moretrees:rubber_tree_sapling_ongen"
moretrees.spawn_willow_object = "moretrees:willow_sapling_ongen"
moretrees.spawn_birch_object = "moretrees:birch_sapling_ongen"
moretrees.spawn_spruce_object = "moretrees:spruce_sapling_ongen"
moretrees.spawn_jungletree_object = "moretrees:jungletree_sapling_ongen"
moretrees.spawn_fir_object = "moretrees:fir_sapling_ongen"
moretrees.spawn_fir_snow_object = "snow:sapling_pine"
moretrees.spawn_poplar_object = "moretrees:poplar_sapling_ongen"
moretrees.spawn_poplar_small_object = "moretrees:poplar_small_sapling_ongen"
else
moretrees.spawn_beech_object = moretrees.beech_model
moretrees.spawn_apple_tree_object = moretrees.apple_tree_model
moretrees.spawn_oak_object = moretrees.oak_model
moretrees.spawn_sequoia_object = moretrees.sequoia_model
moretrees.spawn_palm_object = moretrees.palm_model
moretrees.spawn_date_palm_object = moretrees.date_palm_model
moretrees.spawn_cedar_object = moretrees.cedar_model
moretrees.spawn_rubber_tree_object = moretrees.rubber_tree_model
moretrees.spawn_willow_object = moretrees.willow_model
moretrees.spawn_birch_object = "moretrees.grow_birch"
moretrees.spawn_spruce_object = "moretrees.grow_spruce"
moretrees.spawn_jungletree_object = "moretrees.grow_jungletree"
moretrees.spawn_fir_object = "moretrees.grow_fir"
moretrees.spawn_fir_snow_object = "moretrees.grow_fir_snow"
moretrees.spawn_poplar_object = moretrees.poplar_model
moretrees.spawn_poplar_small_object = moretrees.poplar_small_model
end
moretrees.spawn_beech_object = moretrees.beech_model
moretrees.spawn_apple_tree_object = moretrees.apple_tree_model
moretrees.spawn_oak_object = moretrees.oak_model
moretrees.spawn_sequoia_object = moretrees.sequoia_model
moretrees.spawn_palm_object = moretrees.palm_model
moretrees.spawn_date_palm_object = moretrees.date_palm_model
moretrees.spawn_cedar_object = moretrees.cedar_model
moretrees.spawn_rubber_tree_object = moretrees.rubber_tree_model
moretrees.spawn_willow_object = moretrees.willow_model
moretrees.spawn_birch_object = "moretrees.grow_birch"
moretrees.spawn_spruce_object = "moretrees.grow_spruce"
moretrees.spawn_jungletree_object = "moretrees.grow_jungletree"
moretrees.spawn_fir_object = "moretrees.grow_fir"
moretrees.spawn_fir_snow_object = "moretrees.grow_fir_snow"
moretrees.spawn_poplar_object = moretrees.poplar_model
moretrees.spawn_poplar_small_object = moretrees.poplar_small_model
--[[ if moretrees.enable_beech then
biome_lib:register_generate_plant(moretrees.beech_biome, moretrees.spawn_beech_object)
@ -199,7 +179,7 @@ end ]]
-- Code to spawn a birch tree
function moretrees.grow_birch(pos)
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
if math.random(1,2) == 1 then
minetest.spawn_tree(pos, moretrees.birch_model1)
else
@ -210,7 +190,7 @@ end
-- Code to spawn a spruce tree
function moretrees.grow_spruce(pos)
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
if math.random(1,2) == 1 then
minetest.spawn_tree(pos, moretrees.spruce_model1)
else
@ -264,10 +244,10 @@ function moretrees.grow_jungletree(pos)
moretrees.jungletree_model.rules_b = moretrees.jt_rules_b2
end
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
local leaves = minetest.find_nodes_in_area({x = pos.x-1, y = pos.y, z = pos.z-1}, {x = pos.x+1, y = pos.y+10, z = pos.z+1}, "default:leaves")
for leaf in ipairs(leaves) do
minetest.swap_node(leaves[leaf], biome_lib.air)
minetest.swap_node(leaves[leaf], {name = "air"})
end
minetest.spawn_tree(pos, moretrees.jungletree_model)
end
@ -291,10 +271,10 @@ function moretrees.grow_fir(pos)
moretrees.fir_model.iterations = 7
moretrees.fir_model.random_level = 5
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
local leaves = minetest.find_nodes_in_area({x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, "default:leaves")
for leaf in ipairs(leaves) do
minetest.swap_node(leaves[leaf], biome_lib.air)
minetest.swap_node(leaves[leaf], {name = "air"})
end
minetest.spawn_tree(pos,moretrees.fir_model)
end
@ -318,10 +298,10 @@ function moretrees.grow_fir_snow(pos)
moretrees.fir_model.iterations = 2
moretrees.fir_model.random_level = 2
minetest.swap_node(pos, biome_lib.air)
minetest.swap_node(pos, {name = "air"})
local leaves = minetest.find_nodes_in_area({x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, "default:leaves")
for leaf in ipairs(leaves) do
minetest.swap_node(leaves[leaf], biome_lib.air)
minetest.swap_node(leaves[leaf], {name = "air"})
end
minetest.spawn_tree(pos,moretrees.fir_model)
end

View File

@ -482,6 +482,12 @@ for i in ipairs(moretrees.treelist) do
minetest.chat_send_all("can grow")
minetest.chat_send_all("grow_" .. treename)
--moretrees["grow_" .. treename](pos)
if type(moretrees["spawn_" .. treename .. "_object"])=="string" then
local split = moretrees["spawn_" .. treename .. "_object"]:split(".")
moretrees[split[2]](pos)
else
minetest.spawn_tree(pos, moretrees["spawn_" .. treename .. "_object"])
end
else
minetest.get_node_timer(pos):start(300)
end