diff --git a/forestsoils/abms.lua b/forestsoils/abms.lua new file mode 100644 index 0000000..3291ef3 --- /dev/null +++ b/forestsoils/abms.lua @@ -0,0 +1,35 @@ +--abms + +minetest.register_abm({ + nodenames = {"default:dirt_with_grass"}, + interval = 1, + chance = 3, + action = function(pos) + if minetest.find_node_near({x=pos.x,y=pos.y+1,z=pos.z}, 3, {"group:tree"}) then + minetest.env:add_node(pos, {name="forestsoils:dirt_with_leaves_1"}) + end + end, +}) + +minetest.register_abm({ + nodenames = {"default:dirt_with_grass"}, + interval = 1, + chance = 6, + action = function(pos) + if minetest.find_node_near({x=pos.x,y=pos.y+1,z=pos.z}, 1, {"forestsoils:dirt_with_leaves_1"}) then + minetest.env:add_node(pos, {name="forestsoils:grass_with_leaves_2"}) + end + end, +}) + +minetest.register_abm({ + nodenames = {"default:dirt_with_grass"}, + interval = 1, + chance = 12, + action = function(pos) + if minetest.find_node_near({x=pos.x,y=pos.y+1,z=pos.z}, 1, {"forestsoils:grass_with_leaves_2"}) then + minetest.env:add_node(pos, {name="forestsoils:grass_with_leaves_1"}) + end + + end, +}) \ No newline at end of file diff --git a/forestsoils/depends.txt b/forestsoils/depends.txt new file mode 100644 index 0000000..bde0bdf --- /dev/null +++ b/forestsoils/depends.txt @@ -0,0 +1,2 @@ +default +plants_lib \ No newline at end of file diff --git a/forestsoils/generate.lua b/forestsoils/generate.lua new file mode 100644 index 0000000..a4f4800 --- /dev/null +++ b/forestsoils/generate.lua @@ -0,0 +1,58 @@ +-- generate + +minetest.register_on_generated(function(minp, maxp, seed) + if maxp.y >= 2 and minp.y <= 0 then + -- Generate forest soil + -- perlin like plants_lib default and "default:grass_*" + local perlin1 = minetest.get_perlin(329, 3, 0.6, 100) + -- Assume X and Z lengths are equal + local divlen = 8--16 + local divs = (maxp.x-minp.x)/divlen+1; + for divx=0,divs-1 do + for divz=0,divs-1 do + local x0 = minp.x + math.floor((divx+0)*divlen) + local z0 = minp.z + math.floor((divz+0)*divlen) + local x1 = minp.x + math.floor((divx+1)*divlen) + local z1 = minp.z + math.floor((divz+1)*divlen) + -- dirt_with_leaves_1 + local forest_soil_amount = 100 + -- Find random positions for grass based on this random + local pr = PseudoRandom(seed)--+1) + for i=0,forest_soil_amount do + local x = pr:next(x0, x1) + local z = pr:next(z0, z1) + -- Find ground level (0...38) + local ground_y = nil + for y=38,0,-1 do + local nn = minetest.get_node({x=x,y=y,z=z}).name + if nn == "default:dirt_with_grass" then + ground_y = y + break + end + end + + if ground_y then + local pos = {x=x,y=ground_y,z=z} + local pos1 = {x=x,y=ground_y+1,z=z} + local nn = minetest.get_node(pos).name + -- Check if the node can be replaced + if minetest.find_node_near(pos1, 3, {"group:tree"}) then + if table.getn(minetest.find_nodes_in_area({x=x-3, y=ground_y-1, z=z-3}, {x=x+3, y=ground_y+1, z=z+3}, {"group:tree"})) >= 4 then -- from plants_lib + minetest.set_node(pos,{name="forestsoils:dirt_with_leaves_1"}) + end + end + if minetest.find_node_near(pos, 1, {"forestsoils:dirt_with_leaves_1"}) then + minetest.set_node(pos,{name="forestsoils:grass_with_leaves_2"}) + end + if minetest.find_node_near(pos, 1, {"forestsoils:grass_with_leaves_2"}) then + minetest.set_node(pos,{name="forestsoils:grass_with_leaves_1"}) + end + if minetest.find_node_near(pos, 1, {"forestsoils:grass_with_leaves_1"}) then + minetest.set_node(pos,{name="forestsoils:dirt_with_leaves_2"}) + end + end + end + end + end + end +end) \ No newline at end of file diff --git a/forestsoils/generating.lua b/forestsoils/generating.lua new file mode 100644 index 0000000..d080d3b --- /dev/null +++ b/forestsoils/generating.lua @@ -0,0 +1,71 @@ +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"}) + end +end + +plantslib:register_generate_plant({ + surface = {"default:dirt_with_grass"}, + max_count = 6400, + rarity = 1, + min_elevation = 1, + near_nodes = {"group:tree"}, + near_nodes_size = 3, + near_nodes_vertical = 1, + near_nodes_count = 4, + plantlife_limit = -1, + check_air = false, + }, + "abstract_forestsoils.place_soil" +) + +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"}) + end +end + +plantslib:register_generate_plant({ + surface = {"default:dirt_with_grass"}, + max_count = 6400, + rarity = 1, + min_elevation = 1, + plantlife_limit = -1, + check_air = false, + }, + "abstract_forestsoils.place_soil_2" +) + +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"}) + end +end + +plantslib:register_generate_plant({ + surface = {"default:dirt_with_grass"}, + max_count = 6400, + rarity = 1, + min_elevation = 1, + plantlife_limit = -1, + check_air = false, + }, + "abstract_forestsoils.place_soil_3" +) + +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"}) + end +end + +plantslib:register_generate_plant({ + surface = {"default:dirt_with_grass"}, + max_count = 6400, + rarity = 1, + min_elevation = 1, + plantlife_limit = -1, + check_air = false, + }, + "abstract_forestsoils.place_soil_4" +) \ No newline at end of file diff --git a/forestsoils/init.lua b/forestsoils/init.lua new file mode 100644 index 0000000..9c4c530 --- /dev/null +++ b/forestsoils/init.lua @@ -0,0 +1,16 @@ +----------------------------------------------------------------------------------------------- +local title = "Forrest Soils" +local version = "0.0.3" +local mname = "forestsoils" +----------------------------------------------------------------------------------------------- + +abstract_forestsoils = {} + +dofile(minetest.get_modpath("forestsoils").."/nodes.lua") +--dofile(minetest.get_modpath("forestsoils").."/generate.lua") +--dofile(minetest.get_modpath("forestsoils").."/abms.lua") +dofile(minetest.get_modpath("forestsoils").."/generating.lua") + +----------------------------------------------------------------------------------------------- +print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...") +----------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/forestsoils/nodes.lua b/forestsoils/nodes.lua new file mode 100644 index 0000000..6eab13f --- /dev/null +++ b/forestsoils/nodes.lua @@ -0,0 +1,73 @@ +-- nodes + +minetest.register_node("forestsoils:dirt_with_leaves_1", { + description = "Forrest Soil 1", + tiles = { + "default_dirt.png^leaves_ground_9_cover.png", + "default_dirt.png", + "default_dirt.png^leaves_ground_9_cover_side.png"}, + is_ground_content = true, + groups = { + crumbly=3, + soil=1--, + --not_in_creative_inventory=1 + }, + --drop = 'default:dirt', + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_node("forestsoils:dirt_with_leaves_2", { + description = "Forrest Soil 2", + tiles = { + "leaves_ground_9.png", + "default_dirt.png", + "default_dirt.png^leaves_ground_9_side.png"}, + is_ground_content = true, + groups = { + crumbly=3, + soil=1--, + --not_in_creative_inventory=1 + }, + --drop = 'default:dirt', + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_node("forestsoils:grass_with_leaves_1", { + description = "Forrest Soil 3", + tiles = { + "default_grass.png^leaves_ground_9_cover2.png", + "default_dirt.png", + "default_dirt.png^default_grass_side.png^leaves_ground_9_cover_side2.png"}, + is_ground_content = true, + groups = { + crumbly=3, + soil=1--, + --not_in_creative_inventory=1 + }, + --drop = 'default:dirt', + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_node("forestsoils:grass_with_leaves_2", { + description = "Forrest Soil 4", + tiles = { + "default_grass.png^leaves_ground_9_cover.png", + "default_dirt.png", + "default_dirt.png^default_grass_side.png^leaves_ground_9_cover_side.png"}, + is_ground_content = true, + groups = { + crumbly=3, + soil=1--, + --not_in_creative_inventory=1 + }, + --drop = 'default:dirt', + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) \ No newline at end of file diff --git a/forestsoils/textures/bw_l.png b/forestsoils/textures/bw_l.png new file mode 100644 index 0000000..e34901d Binary files /dev/null and b/forestsoils/textures/bw_l.png differ diff --git a/forestsoils/textures/dryplants_grass_short.png b/forestsoils/textures/dryplants_grass_short.png new file mode 100644 index 0000000..ad186e5 Binary files /dev/null and b/forestsoils/textures/dryplants_grass_short.png differ diff --git a/forestsoils/textures/leaves_ground.png b/forestsoils/textures/leaves_ground.png new file mode 100644 index 0000000..ea657c4 Binary files /dev/null and b/forestsoils/textures/leaves_ground.png differ diff --git a/forestsoils/textures/leaves_ground_2.png b/forestsoils/textures/leaves_ground_2.png new file mode 100644 index 0000000..ad31879 Binary files /dev/null and b/forestsoils/textures/leaves_ground_2.png differ diff --git a/forestsoils/textures/leaves_ground_3.png b/forestsoils/textures/leaves_ground_3.png new file mode 100644 index 0000000..7946997 Binary files /dev/null and b/forestsoils/textures/leaves_ground_3.png differ diff --git a/forestsoils/textures/leaves_ground_4.png b/forestsoils/textures/leaves_ground_4.png new file mode 100644 index 0000000..919bdd3 Binary files /dev/null and b/forestsoils/textures/leaves_ground_4.png differ diff --git a/forestsoils/textures/leaves_ground_5.png b/forestsoils/textures/leaves_ground_5.png new file mode 100644 index 0000000..0e91573 Binary files /dev/null and b/forestsoils/textures/leaves_ground_5.png differ diff --git a/forestsoils/textures/leaves_ground_6.png b/forestsoils/textures/leaves_ground_6.png new file mode 100644 index 0000000..0f7ffee Binary files /dev/null and b/forestsoils/textures/leaves_ground_6.png differ diff --git a/forestsoils/textures/leaves_ground_7.png b/forestsoils/textures/leaves_ground_7.png new file mode 100644 index 0000000..870c213 Binary files /dev/null and b/forestsoils/textures/leaves_ground_7.png differ diff --git a/forestsoils/textures/leaves_ground_8.png b/forestsoils/textures/leaves_ground_8.png new file mode 100644 index 0000000..8f7b6cf Binary files /dev/null and b/forestsoils/textures/leaves_ground_8.png differ diff --git a/forestsoils/textures/leaves_ground_8_cover.png b/forestsoils/textures/leaves_ground_8_cover.png new file mode 100644 index 0000000..dd668bc Binary files /dev/null and b/forestsoils/textures/leaves_ground_8_cover.png differ diff --git a/forestsoils/textures/leaves_ground_8_cover_side.png b/forestsoils/textures/leaves_ground_8_cover_side.png new file mode 100644 index 0000000..f2bdddc Binary files /dev/null and b/forestsoils/textures/leaves_ground_8_cover_side.png differ diff --git a/forestsoils/textures/leaves_ground_8_side.png b/forestsoils/textures/leaves_ground_8_side.png new file mode 100644 index 0000000..591b552 Binary files /dev/null and b/forestsoils/textures/leaves_ground_8_side.png differ diff --git a/forestsoils/textures/leaves_ground_9.png b/forestsoils/textures/leaves_ground_9.png new file mode 100644 index 0000000..9001b2e Binary files /dev/null and b/forestsoils/textures/leaves_ground_9.png differ diff --git a/forestsoils/textures/leaves_ground_9_cover.png b/forestsoils/textures/leaves_ground_9_cover.png new file mode 100644 index 0000000..1168adc Binary files /dev/null and b/forestsoils/textures/leaves_ground_9_cover.png differ diff --git a/forestsoils/textures/leaves_ground_9_cover2.png b/forestsoils/textures/leaves_ground_9_cover2.png new file mode 100644 index 0000000..bb3dda2 Binary files /dev/null and b/forestsoils/textures/leaves_ground_9_cover2.png differ diff --git a/forestsoils/textures/leaves_ground_9_cover_side.png b/forestsoils/textures/leaves_ground_9_cover_side.png new file mode 100644 index 0000000..ac1393b Binary files /dev/null and b/forestsoils/textures/leaves_ground_9_cover_side.png differ diff --git a/forestsoils/textures/leaves_ground_9_cover_side2.png b/forestsoils/textures/leaves_ground_9_cover_side2.png new file mode 100644 index 0000000..acea830 Binary files /dev/null and b/forestsoils/textures/leaves_ground_9_cover_side2.png differ diff --git a/forestsoils/textures/leaves_ground_9_side.png b/forestsoils/textures/leaves_ground_9_side.png new file mode 100644 index 0000000..fbca9d6 Binary files /dev/null and b/forestsoils/textures/leaves_ground_9_side.png differ