forked from mtcontrib/moreplants
		
	replace plant abm with on_generated
replaced plant abm with on_generated so that underground plants are placed in new areas, this also removes the over-generation bug from using an abm.
This commit is contained in:
		
							
								
								
									
										41
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								init.lua
									
									
									
									
									
								
							| @@ -862,31 +862,28 @@ minetest.register_decoration({ | |||||||
| }) | }) | ||||||
| end | end | ||||||
|  |  | ||||||
| --ABM spawning | -- Spawn underground plants in newly generated areas | ||||||
| -- ABM from the Mushroom mod |  | ||||||
| --by DanDuncombe and VanessaE |  | ||||||
| -- License of code ; WTFPL |  | ||||||
|  |  | ||||||
| -- Natural Spawning ABM | local frequency = 200 | ||||||
| minetest.register_abm({ |  | ||||||
| nodenames = { | minetest.register_on_generated(function(minp, maxp) | ||||||
| "default:stone", | 	if maxp.y > 0 then | ||||||
| }, | 		return | ||||||
| neighbors = {"air"}, | 	end | ||||||
| interval = 500, | 	local stone = minetest.find_nodes_in_area_under_air(minp, maxp, | ||||||
| chance = 200, | 		{"default:stone", "default:desert_stone"}) | ||||||
| action = function(pos, node) | 	for n = 1, #stone do | ||||||
| local top_pos = {x=pos.x, y=pos.y+1, z=pos.z} | 		if math.random(1, frequency) == 1 then | ||||||
| if minetest.get_node(top_pos).name == "air" then | 			local pos = {x = stone[n].x, y = stone[n].y + 1, z = stone[n].z } | ||||||
| if minetest.find_node_near(pos, 3, {"default:lava_source"}) then | 			if minetest.find_node_near(pos, 3, {"group:lava"}) then | ||||||
| minetest.add_node(top_pos, {name="moreplants:firefung"}) | 				minetest.add_node(pos, {name = "moreplants:firefung"}) | ||||||
| elseif minetest.get_node_light(top_pos, nil) < 8 then | 			elseif minetest.get_node_light(pos, nil) < 8 then | ||||||
| if minetest.find_node_near(pos, 3, {"default:water_source"}) then | 				if minetest.find_node_near(pos, 3, {"group:water"}) then | ||||||
| minetest.add_node(top_pos, {name="moreplants:bluemush"}) | 					minetest.add_node(pos, {name = "moreplants:bluemush"}) | ||||||
| 				else | 				else | ||||||
| minetest.add_node(top_pos, {name="moreplants:caveflower"}) | 					minetest.add_node(pos, {name = "moreplants:caveflower"}) | ||||||
| 				end | 				end | ||||||
| 			end | 			end | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| }) | end) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user