From 069387dab5da7267c85bb4e46374134e50af2f1f Mon Sep 17 00:00:00 2001 From: Mossmanikin Date: Fri, 20 Sep 2013 00:08:58 +0200 Subject: [PATCH] forest soil near some pebbles --- forestsoils/generating.lua | 52 ++++++++++++++++++++++++++++++++------ forestsoils/init.lua | 2 +- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/forestsoils/generating.lua b/forestsoils/generating.lua index d080d3b..b12331c 100644 --- a/forestsoils/generating.lua +++ b/forestsoils/generating.lua @@ -1,6 +1,11 @@ +-- generating of forest soils + abstract_forestsoils.place_soil = function(pos) - if minetest.find_node_near(pos, 3, {"group:tree"}) then - minetest.add_node(pos, {name="forestsoils:dirt_with_leaves_1"}) + local node_here = minetest.get_node(pos) + if minetest.registered_nodes[node_here.name] then -- instead of check_air = true, + if minetest.find_node_near(pos, 3, {"group:tree"}) then + minetest.add_node(pos, {name="forestsoils:dirt_with_leaves_1"}) + end end end @@ -19,9 +24,34 @@ plantslib:register_generate_plant({ "abstract_forestsoils.place_soil" ) +abstract_forestsoils.place_soil_1 = function(pos) + local node_here = minetest.get_node(pos) + local node_above = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) + if minetest.registered_nodes[node_here.name] then -- instead of check_air = true, + if string.find(node_above.name, "bush") -- doesn't work, just here as a "reminder" + or string.find(node_above.name, "pebble") then + minetest.add_node(pos, {name="forestsoils:dirt_with_leaves_1"}) + end + end +end + +plantslib:register_generate_plant({ + surface = {"default:dirt_with_grass"}, + max_count = 6400, + rarity = 67, + min_elevation = 1, + plantlife_limit = -1, + check_air = false, + }, + "abstract_forestsoils.place_soil_1" +) + abstract_forestsoils.place_soil_2 = function(pos) - if minetest.find_node_near(pos, 1, {"forestsoils:dirt_with_leaves_1"}) then - minetest.add_node(pos, {name="forestsoils:grass_with_leaves_2"}) + local node_here = minetest.get_node(pos) + if minetest.registered_nodes[node_here.name] then -- instead of check_air = true, + if minetest.find_node_near(pos, 1, {"forestsoils:dirt_with_leaves_1"}) then + minetest.add_node(pos, {name="forestsoils:grass_with_leaves_2"}) + end end end @@ -37,8 +67,11 @@ plantslib:register_generate_plant({ ) abstract_forestsoils.place_soil_3 = function(pos) - if minetest.find_node_near(pos, 1, {"forestsoils:grass_with_leaves_2"}) then - minetest.add_node(pos, {name="forestsoils:grass_with_leaves_1"}) + local node_here = minetest.get_node(pos) + if minetest.registered_nodes[node_here.name] then -- instead of check_air = true, + if minetest.find_node_near(pos, 1, {"forestsoils:grass_with_leaves_2"}) then + minetest.add_node(pos, {name="forestsoils:grass_with_leaves_1"}) + end end end @@ -54,8 +87,11 @@ plantslib:register_generate_plant({ ) abstract_forestsoils.place_soil_4 = function(pos) - if minetest.find_node_near(pos, 1, {"forestsoils:dirt_with_leaves_1"}) then - minetest.add_node(pos, {name="forestsoils:dirt_with_leaves_2"}) + local node_here = minetest.get_node(pos) + if minetest.registered_nodes[node_here.name] then -- instead of check_air = true, + if minetest.find_node_near(pos, 1, {"forestsoils:dirt_with_leaves_1"}) then + minetest.add_node(pos, {name="forestsoils:dirt_with_leaves_2"}) + end end end diff --git a/forestsoils/init.lua b/forestsoils/init.lua index 9c4c530..e859a4e 100644 --- a/forestsoils/init.lua +++ b/forestsoils/init.lua @@ -1,6 +1,6 @@ ----------------------------------------------------------------------------------------------- local title = "Forrest Soils" -local version = "0.0.3" +local version = "0.0.4" local mname = "forestsoils" -----------------------------------------------------------------------------------------------