Tweaked how flowers spread
This commit is contained in:
parent
4f3f8b2c3a
commit
dbcd9e18e3
52
flowers.lua
52
flowers.lua
@ -2,46 +2,68 @@
|
|||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"group:flora"},
|
nodenames = {"group:flora"},
|
||||||
neighbors = {"group:soil"},
|
neighbors = {"group:soil"},
|
||||||
interval = 50,
|
interval = 20,
|
||||||
chance = 20,
|
chance = 5,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
|
|
||||||
local light = minetest.get_node_light(pos)
|
local light = minetest.get_node_light(pos)
|
||||||
|
|
||||||
if not light or light < 13 then
|
if not light
|
||||||
|
or light < 13 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos0 = {x = pos.x - 4, y = pos.y - 2, z = pos.z - 4}
|
local pos0 = {x = pos.x - 4, y = pos.y - 2, z = pos.z - 4}
|
||||||
local pos1 = {x = pos.x + 4, y = pos.y + 2, z = pos.z + 4}
|
local pos1 = {x = pos.x + 4, y = pos.y + 2, z = pos.z + 4}
|
||||||
|
local num = #minetest.find_nodes_in_area_under_air(
|
||||||
|
pos0, pos1, "group:flora")
|
||||||
|
|
||||||
if #minetest.find_nodes_in_area_under_air(pos0, pos1, "group:flora") > 3 then
|
if num > 3
|
||||||
|
and node.name == "ethereal:crystalgrass" then
|
||||||
|
|
||||||
local grass = minetest.find_nodes_in_area_under_air(pos0, pos1, {"ethereal:crystalgrass"})
|
local grass = minetest.find_nodes_in_area_under_air(
|
||||||
local crystal = minetest.find_nodes_in_area_under_air(pos0, pos1, {"ethereal:crystal_spike"})
|
pos0, pos1, {"ethereal:crystalgrass"})
|
||||||
|
|
||||||
|
local crystal = minetest.find_nodes_in_area_under_air(
|
||||||
|
pos0, pos1, {"ethereal:crystal_spike"})
|
||||||
|
|
||||||
|
if #grass > 4
|
||||||
|
and #crystal < 1 then
|
||||||
|
|
||||||
if #grass > 6 and #crystal < 1 then
|
|
||||||
grass = grass[math.random(#grass)]
|
grass = grass[math.random(#grass)]
|
||||||
|
|
||||||
grass.y = grass.y - 1
|
grass.y = grass.y - 1
|
||||||
|
|
||||||
if minetest.get_node(grass).name == "ethereal:crystal_dirt" then
|
if minetest.get_node(grass).name == "ethereal:crystal_dirt" then
|
||||||
|
|
||||||
grass.y = grass.y + 1
|
grass.y = grass.y + 1
|
||||||
|
|
||||||
minetest.set_node(grass, {name = "ethereal:crystal_spike"})
|
minetest.set_node(grass, {name = "ethereal:crystal_spike"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
|
||||||
|
|
||||||
local seedling = minetest.find_nodes_in_area_under_air(pos0, pos1, {"group:soil"})
|
elseif num > 3 then
|
||||||
|
|
||||||
if #seedling > 0 then
|
|
||||||
seedling = seedling[math.random(#seedling)]
|
|
||||||
seedling.y = seedling.y + 1
|
|
||||||
light = minetest.get_node_light(seedling)
|
|
||||||
if not light or light < 13 then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local seedling = minetest.find_nodes_in_area_under_air(
|
||||||
|
pos0, pos1, {"group:soil"})
|
||||||
|
|
||||||
|
if #seedling > 0 then
|
||||||
|
|
||||||
|
seedling = seedling[math.random(#seedling)]
|
||||||
|
seedling.y = seedling.y + 1
|
||||||
|
|
||||||
|
light = minetest.get_node_light(seedling)
|
||||||
|
|
||||||
|
if not light
|
||||||
|
or light < 13 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if minetest.get_node(seedling).name == "air" then
|
if minetest.get_node(seedling).name == "air" then
|
||||||
minetest.set_node(seedling, {name = node.name})
|
minetest.set_node(seedling, {name = node.name})
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user