forest soils

master
Mossmanikin 2013-09-18 14:19:14 +02:00
parent a154c9c132
commit 06a121cfa7
25 changed files with 255 additions and 0 deletions

35
forestsoils/abms.lua Normal file
View File

@ -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,
})

2
forestsoils/depends.txt Normal file
View File

@ -0,0 +1,2 @@
default
plants_lib

58
forestsoils/generate.lua Normal file
View File

@ -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)

View File

@ -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"
)

16
forestsoils/init.lua Normal file
View File

@ -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...")
-----------------------------------------------------------------------------------------------

73
forestsoils/nodes.lua Normal file
View File

@ -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},
}),
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 834 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B