forked from minetest/minetest_game
Flowers: Tweak flower and mushroom spreading
Tidy up position numbers and code Check for flora group aswell Improve node light check for mushroom growth Shrooms grow in 3 and below light
This commit is contained in:
parent
7d93272caa
commit
9ece86cc7a
@ -83,6 +83,7 @@ minetest.register_abm({
|
|||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
if under.name == "default:desert_sand" then
|
if under.name == "default:desert_sand" then
|
||||||
minetest.set_node(pos, {name = "default:dry_shrub"})
|
minetest.set_node(pos, {name = "default:dry_shrub"})
|
||||||
|
return
|
||||||
elseif under.name ~= "default:dirt_with_grass" then
|
elseif under.name ~= "default:dirt_with_grass" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -92,18 +93,14 @@ minetest.register_abm({
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos0 = {x = pos.x - 4, y = pos.y - 4, z = pos.z - 4}
|
local pos0 = vector.subtract(pos, 4)
|
||||||
local pos1 = {x = pos.x + 4, y = pos.y + 4, z = pos.z + 4}
|
local pos1 = vector.add(pos, 4)
|
||||||
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
|
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora") > 3 or
|
||||||
|
#minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
|
local seedling = minetest.find_nodes_in_area_under_air(pos0, pos1, "default:dirt_with_grass")
|
||||||
if #flowers > 3 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local seedling = minetest.find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
|
|
||||||
if #seedling > 0 then
|
if #seedling > 0 then
|
||||||
seedling = seedling[math.random(#seedling)]
|
seedling = seedling[math.random(#seedling)]
|
||||||
seedling.y = seedling.y + 1
|
seedling.y = seedling.y + 1
|
||||||
@ -111,10 +108,8 @@ minetest.register_abm({
|
|||||||
if not light or light < 13 then
|
if not light or light < 13 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.get_node(seedling).name == "air" then
|
|
||||||
minetest.set_node(seedling, {name = node.name})
|
minetest.set_node(seedling, {name = node.name})
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -169,6 +164,7 @@ minetest.register_abm({
|
|||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if minetest.get_node_light(pos, nil) == 15 then
|
if minetest.get_node_light(pos, nil) == 15 then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
local random = {
|
local random = {
|
||||||
x = pos.x + math.random(-2, 2),
|
x = pos.x + math.random(-2, 2),
|
||||||
@ -176,10 +172,7 @@ minetest.register_abm({
|
|||||||
z = pos.z + math.random(-2, 2)
|
z = pos.z + math.random(-2, 2)
|
||||||
}
|
}
|
||||||
local random_node = minetest.get_node_or_nil(random)
|
local random_node = minetest.get_node_or_nil(random)
|
||||||
if not random_node then
|
if not random_node or random_node.name ~= "air" then
|
||||||
return
|
|
||||||
end
|
|
||||||
if random_node.name ~= "air" then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local node_under = minetest.get_node_or_nil({x = random.x,
|
local node_under = minetest.get_node_or_nil({x = random.x,
|
||||||
@ -187,9 +180,11 @@ minetest.register_abm({
|
|||||||
if not node_under then
|
if not node_under then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.get_item_group(node_under.name, "soil") ~= 0 and
|
|
||||||
minetest.get_node_light(pos, nil) <= 9 and
|
if (minetest.get_item_group(node_under.name, "soil") ~= 0 or
|
||||||
minetest.get_node_light(random, nil) <= 9 then
|
minetest.get_item_group(node_under.name, "tree") ~= 0) and
|
||||||
|
minetest.get_node_light(pos, 0.5) <= 3 and
|
||||||
|
minetest.get_node_light(random, 0.5) <= 3 then
|
||||||
minetest.set_node(random, {name = node.name})
|
minetest.set_node(random, {name = node.name})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user