@@ -139,32 +139,37 @@ function flowers.flower_spread(pos, node)
139
139
140
140
local pos0 = vector .subtract (pos , 4 )
141
141
local pos1 = vector .add (pos , 4 )
142
- if # minetest .find_nodes_in_area (pos0 , pos1 , " group:flora" ) > 3 then
142
+ -- Maximum flower density created by mapgen is 13 per 9x9 area.
143
+ -- The limit of 7 below was tuned by in-game testing to result in a maximum
144
+ -- flower density by ABM spread of 13 per 9x9 area.
145
+ -- Warning: Setting this limit theoretically without in-game testing
146
+ -- results in a maximum flower density by ABM spread that is far too high.
147
+ if # minetest .find_nodes_in_area (pos0 , pos1 , " group:flora" ) > 7 then
143
148
return
144
149
end
145
150
146
151
local soils = minetest .find_nodes_in_area_under_air (
147
152
pos0 , pos1 , " group:soil" )
148
- if # soils > 0 then
149
- local seedling = soils [math.random (# soils )]
150
- local seedling_above =
151
- {x = seedling .x , y = seedling .y + 1 , z = seedling .z }
152
- light = minetest .get_node_light (seedling_above )
153
- if not light or light < 13 or
154
- -- Desert sand is in the soil group
155
- minetest .get_node (seedling ).name == " default:desert_sand" then
156
- return
153
+ local num_soils = # soils
154
+ if num_soils >= 1 then
155
+ for si = 1 , math.min (3 , num_soils ) do
156
+ local soil = soils [math.random (num_soils )]
157
+ local soil_above = {x = soil .x , y = soil .y + 1 , z = soil .z }
158
+ light = minetest .get_node_light (soil_above )
159
+ if light and light >= 13 and
160
+ -- Desert sand is in the soil group
161
+ minetest .get_node (soil ).name ~= " default:desert_sand" then
162
+ minetest .set_node (soil_above , {name = node .name })
163
+ end
157
164
end
158
-
159
- minetest .set_node (seedling_above , {name = node .name })
160
165
end
161
166
end
162
167
163
168
minetest .register_abm ({
164
169
label = " Flower spread" ,
165
170
nodenames = {" group:flora" },
166
171
interval = 13 ,
167
- chance = 96 ,
172
+ chance = 300 ,
168
173
action = function (...)
169
174
flowers .flower_spread (... )
170
175
end ,
0 commit comments