21 Commits

Author SHA1 Message Date
5ac025cda4 Merge remote-tracking branch 'upstream/master' 2021-07-03 17:29:19 +02:00
52b2d18523 make moss buildable_to
and make sunflower attached_node like other plants
2021-06-29 13:44:00 -04:00
efe869d386 Fix crash caused by the previous merge 2021-06-26 20:04:36 +02:00
b597f99014 Merge remote-tracking branch 'upstream/master' 2021-06-26 19:07:22 +02:00
bfd08f01c8 Just run the conversion LBM on every load
it won't take any appreciable CPU anyway if there's nothing to do.

Minetest seems to not new (or newly-renamed) LBMs when it should, when
it's set to only run once.  Also covers cases where a crash could
prevent mapblocks being checked later.
2021-06-23 21:09:48 -04:00
9ed4771515 fix rare edge-case where unknown nodes cause a crash
When a new mapblock is generated and the mod checks the neighbors around
a target to place a fallen twig, if it finds an unknown node (because
it's in a neighboring, old mapblock from a previous session -- perhaps
an old moss node that hadn't converted-over to wallmounted yet), trying
to check its buildable_to state will fail, since that requires that
there be a node def to look at, which an unknown node wouldn't have.

This substitutes a known not-buildable_to node for those cases, so that
the code won't try to overwrite what it found.
2021-06-23 21:03:06 -04:00
3f107a8067 renamed the LBM in case it got run at the wrong time
between mod updates; forces it to run again
(it's harmless to let it run twice)
2021-06-23 10:09:58 -04:00
b3cbd3df2e fix moss node drops 2021-06-21 05:21:34 -04:00
b1b4a08834 make pebbles fall when ground is dug. 2021-06-21 00:36:14 -04:00
f01e4bb55f Convert moss to wallmounted mode
I couldn't use leaf decay to make moss disappear when a trunk is dug,
because it breaks leaf decay on that tree's leaves: the leafdecay
function is not a true "register"- type function that can be run more
than once on a given trunk node, it's an all-or-nothing override and
only the last call for any given trunk actually sticks.

Since moss is... was facedir, attached_node didn't work right either, as
it doesn't have a mode to look for a vertical surface behind the
attached object (like how it works with wallmounted items), so this
converts moss to true wallmounted and uses attached_node like I
originally wanted.

To avoid losing the effect where moss can be rotated randomly when
generated, I registered 4 nodes for each moss type, with
increasingly-rotated textures.
2021-06-20 23:30:26 -04:00
637f96e215 Merge remote-tracking branch 'upstream/master' 2021-06-20 17:27:50 +02:00
7b4f54ead0 make youngtrees, bushes fall on dig,
make moss fall when the node holding it is dug,
and make trunk roots decay (exploiting the standard leafdecay function)
2021-06-19 20:36:36 -04:00
c061ef23cf Merge branch 'bls-197' into 'master'
Fixes bug with stalactite placement

See merge request VanessaE/plantlife_modpack!7
2021-06-07 17:04:31 +00:00
d87d8e51f5 Fixes bug with stalactite placement 2021-06-07 17:04:31 +00:00
fa9f30043f Merge remote-tracking branch 'upstream/master' 2021-04-08 13:38:00 +02:00
70df655a42 allow pebbles to spawn on a few more surface types 2021-04-06 04:09:34 -04:00
4876fc1265 let biome_lib place pebbles instead of using custom mapgen code 2021-04-06 04:08:41 -04:00
81b2b0898b don't use a function to pick random dry grasses
just use `biome_lib`'s random-choice table feature
(it was only there to let the mod replace junglegrass, but that's pointless
when junglegrass doesn't tend to spawn in the same areas)
2021-04-06 03:32:04 -04:00
d97f25e112 Merge remote-tracking branch 'upstream/master' 2021-02-13 14:19:21 +01:00
a750bac532 Merge branch 'master' into 'master'
Made woodsoils soils tillable.

See merge request VanessaE/plantlife_modpack!6
2021-02-07 23:29:08 +00:00
b4b24dedba Made woodsoils soils tillable. 2021-02-07 21:17:29 +01:00
11 changed files with 296 additions and 210 deletions

View File

@ -28,7 +28,7 @@ node_box = {
{-0.0612,-0.500000,-0.500000,0.0612,0.500000,-0.375000}, --NodeBox 1 {-0.0612,-0.500000,-0.500000,0.0612,0.500000,-0.375000}, --NodeBox 1
} }
}, },
groups = {snappy=3,flammable=2}, groups = {snappy=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
drop = 'default:stick' drop = 'default:stick'
}) })
@ -63,7 +63,8 @@ for i in pairs(BushBranchCenter) do
-- tree=1, -- MM: disabled because some recipes use group:tree for trunks -- tree=1, -- MM: disabled because some recipes use group:tree for trunks
snappy=3, snappy=3,
flammable=2, flammable=2,
leaves=1 leaves=1,
attached_node=1
}, },
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
drop = 'default:stick 4' drop = 'default:stick 4'
@ -106,7 +107,8 @@ for i in pairs(BushBranchSide) do
-- tree=1, -- MM: disabled because some recipes use group:tree for trunks -- tree=1, -- MM: disabled because some recipes use group:tree for trunks
snappy=3, snappy=3,
flammable=2, flammable=2,
leaves=1 leaves=1,
attached_node=1
}, },
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
drop = 'default:stick 3' drop = 'default:stick 3'

View File

@ -7,6 +7,8 @@ local mname = "cavestuff"
-- support for i18n -- support for i18n
local S = minetest.get_translator("cavestuff") local S = minetest.get_translator("cavestuff")
cavestuff = {}
dofile(minetest.get_modpath("cavestuff").."/nodes.lua") dofile(minetest.get_modpath("cavestuff").."/nodes.lua")
dofile(minetest.get_modpath("cavestuff").."/mapgen.lua") dofile(minetest.get_modpath("cavestuff").."/mapgen.lua")

View File

@ -1,55 +1,39 @@
--Map Generation Stuff --Map Generation Stuff
local random = math.random biome_lib:register_generate_plant(
local floor = math.floor {
surface = {
"default:dirt_with_grass",
"default:gravel",
"default:stone",
"default:permafrost_with_stones"
},
max_count = 50,
rarity = 0,
plantlife_limit = -1,
check_air = true,
random_facedir = {0, 3}
},
{
"cavestuff:pebble_1",
"cavestuff:pebble_2"
}
)
minetest.register_on_generated(function(minp, maxp, seed) biome_lib:register_generate_plant(
if maxp.y >= 2 and minp.y <= 0 then {
-- Generate pebbles surface = {
local perlin1 = minetest.get_perlin(329, 3, 0.6, 100) "default:desert_sand",
-- Assume X and Z lengths are equal "default:desert_stone"
local divlen = 16 },
local divs = (maxp.x-minp.x)/divlen+1; max_count = 50,
for divx=0,divs-1 do rarity = 0,
for divz=0,divs-1 do plantlife_limit = -1,
local x0 = minp.x + floor((divx+0)*divlen) check_air = true,
local z0 = minp.z + floor((divz+0)*divlen) random_facedir = {0, 3}
local x1 = minp.x + floor((divx+1)*divlen) },
local z1 = minp.z + floor((divz+1)*divlen) {
-- Determine pebble amount from perlin noise "cavestuff:desert_pebble_1",
local pebble_amount = floor(perlin1:get2d({x=x0, y=z0}) ^ 2 * 2) "cavestuff:desert_pebble_2"
-- Find random positions for pebbles based on this random }
local pr = PseudoRandom(seed+1) )
for i=0,pebble_amount do
local x = pr:next(x0, x1)
local z = pr:next(z0, z1)
-- Find ground level (0...15)
local ground_y = nil
for y=30,0,-1 do
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
ground_y = y
break
end
end
if ground_y then
local p = {x=x,y=ground_y+1,z=z}
local nn = minetest.get_node(p).name
-- Check if the node can be replaced
if minetest.registered_nodes[nn] and
minetest.registered_nodes[nn].buildable_to then
nn = minetest.get_node({x=x,y=ground_y,z=z}).name
-- If desert sand, add dry shrub
if nn == "default:dirt_with_grass" then
minetest.swap_node(p,{name="cavestuff:pebble_"..pr:next(1,2), param2=random(0,3)})
elseif nn == "default:desert_sand" then
minetest.swap_node(p,{name="cavestuff:desert_pebble_"..pr:next(1,2), param2=random(0,3)})
end
end
end
end
end
end
end
end)

View File

@ -1,2 +1,2 @@
name = cavestuff name = cavestuff
depends = default depends = default,biome_lib

View File

@ -14,65 +14,65 @@ minetest.register_node("cavestuff:pebble_1",{
description = S("Pebble"), description = S("Pebble"),
drawtype = "mesh", drawtype = "mesh",
mesh = "cavestuff_pebble.obj", mesh = "cavestuff_pebble.obj",
tiles = {"undergrowth_pebble.png"}, tiles = {"undergrowth_pebble.png"},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {cracky=3, stone=1}, groups = {cracky=3, stone=1, attached_node=1},
selection_box = cbox, selection_box = cbox,
collision_box = cbox, collision_box = cbox,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
-- place a random pebble node -- place a random pebble node
local stack = ItemStack("cavestuff:pebble_"..random(1,2)) local stack = ItemStack("cavestuff:pebble_"..random(1,2))
local ret = minetest.item_place(stack, placer, pointed_thing) local ret = minetest.item_place(stack, placer, pointed_thing)
return ItemStack("cavestuff:pebble_1 "..itemstack:get_count()-(1-ret:get_count())) return ItemStack("cavestuff:pebble_1 "..itemstack:get_count()-(1-ret:get_count()))
end, end,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
minetest.register_node("cavestuff:pebble_2",{ minetest.register_node("cavestuff:pebble_2",{
drawtype = "mesh", drawtype = "mesh",
mesh = "cavestuff_pebble.obj", mesh = "cavestuff_pebble.obj",
tiles = {"undergrowth_pebble.png"}, tiles = {"undergrowth_pebble.png"},
drop = "cavestuff:pebble_1", drop = "cavestuff:pebble_1",
tiles = {"undergrowth_pebble.png"}, tiles = {"undergrowth_pebble.png"},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {cracky=3, stone=1, not_in_creative_inventory=1}, groups = {cracky=3, stone=1, attached_node=1, not_in_creative_inventory=1},
selection_box = cbox, selection_box = cbox,
collision_box = cbox, collision_box = cbox,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
minetest.register_node("cavestuff:desert_pebble_1",{ minetest.register_node("cavestuff:desert_pebble_1",{
description = S("Desert Pebble"), description = S("Desert Pebble"),
drawtype = "mesh", drawtype = "mesh",
mesh = "cavestuff_pebble.obj", mesh = "cavestuff_pebble.obj",
tiles = {"default_desert_stone.png"}, tiles = {"default_desert_stone.png"},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {cracky=3, stone=1}, groups = {cracky=3, stone=1, attached_node=1},
selection_box = cbox, selection_box = cbox,
collision_box = cbox, collision_box = cbox,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
-- place a random pebble node -- place a random pebble node
local stack = ItemStack("cavestuff:desert_pebble_"..random(1,2)) local stack = ItemStack("cavestuff:desert_pebble_"..random(1,2))
local ret = minetest.item_place(stack, placer, pointed_thing) local ret = minetest.item_place(stack, placer, pointed_thing)
return ItemStack("cavestuff:desert_pebble_1 "..itemstack:get_count()-(1-ret:get_count())) return ItemStack("cavestuff:desert_pebble_1 "..itemstack:get_count()-(1-ret:get_count()))
end, end,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
minetest.register_node("cavestuff:desert_pebble_2",{ minetest.register_node("cavestuff:desert_pebble_2",{
drawtype = "mesh", drawtype = "mesh",
mesh = "cavestuff_pebble.obj", mesh = "cavestuff_pebble.obj",
drop = "cavestuff:desert_pebble_1", drop = "cavestuff:desert_pebble_1",
tiles = {"default_desert_stone.png"}, tiles = {"default_desert_stone.png"},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {cracky=3, stone=1, not_in_creative_inventory=1}, groups = {cracky=3, stone=1, attached_node=1, not_in_creative_inventory=1},
selection_box = cbox, selection_box = cbox,
collision_box = cbox, collision_box = cbox,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
--Staclactites --Staclactites
@ -87,19 +87,34 @@ minetest.register_node("cavestuff:stalactite_1",{
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.187500,0.425000,-0.150003,0.162500,0.500000,0.162500}, {-0.187500,-0.425000,-0.150003,0.162500,-0.500000,0.162500},
{-0.112500,0.162500,-0.100000,0.087500,0.475000,0.087500}, {-0.112500,-0.162500,-0.100000,0.087500,-0.475000,0.087500},
{-0.062500,-0.275000,-0.062500,0.062500,0.500000,0.062500}, {-0.062500,0.275000,-0.062500,0.062500,-0.500000,0.062500},
{-0.037500,-0.837500,0.037500,0.037500,0.500000,-0.025000}, {-0.037500,0.837500,0.037500,0.037500,-0.500000,-0.025000},
} }
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local pt = pointed_thing local dir = vector.subtract(pointed_thing.above, pointed_thing.under)
if minetest.get_node(pt.under).name=="default:stone" local base = pointed_thing.under
and minetest.get_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}).name=="air" local place = vector.add(base, dir)
and minetest.get_node({x=pt.under.x, y=pt.under.y-2, z=pt.under.z}).name=="air" then local above = vector.add(place, dir)
minetest.swap_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}, {name="cavestuff:stalactite_"..random(1,3)})
if not placer then return end
local playername = placer:get_player_name()
if minetest.is_protected(place, playername)
or minetest.is_protected(above, playername) then
minetest.record_protection_violation(place, playername)
return
end
if minetest.get_node(base).name == "default:stone"
and minetest.get_node(place).name == "air"
and minetest.get_node(above).name == "air"
then
minetest.swap_node(place, {
name = "cavestuff:stalactite_"..math.random(1,3),
param2 = minetest.dir_to_wallmounted(vector.multiply(dir, -1))
})
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
itemstack:take_item() itemstack:take_item()
end end
@ -118,10 +133,10 @@ minetest.register_node("cavestuff:stalactite_2",{
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.187500,0.387500,-0.150003,0.162500,0.500000,0.162500}, {-0.187500,-0.387500,-0.150003,0.162500,-0.500000,0.162500},
{-0.112500,0.112500,-0.100000,0.087500,0.475000,0.087500}, {-0.112500,-0.112500,-0.100000,0.087500,-0.475000,0.087500},
{-0.062500,-0.675000,-0.062500,0.062500,0.500000,0.062500}, {-0.062500,0.675000,-0.062500,0.062500,-0.500000,0.062500},
{-0.037500,-0.975000,0.037500,0.037500,0.500000,-0.025000}, {-0.037500,0.975000,0.037500,0.037500,-0.500000,-0.025000},
} }
}, },
}) })
@ -134,14 +149,14 @@ minetest.register_node("cavestuff:stalactite_3",{
paramtype = "light", paramtype = "light",
paramtype2 = "wallmounted", paramtype2 = "wallmounted",
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.187500,0.387500,-0.150003,0.162500,0.500000,0.162500}, {-0.187500,-0.387500,-0.150003,0.162500,-0.500000,0.162500},
{-0.112500,0.037500,-0.100000,0.087500,0.475000,0.087500}, {-0.112500,-0.037500,-0.100000,0.087500,-0.475000,0.087500},
{-0.062500,-0.437500,-0.062500,0.062500,0.500000,0.062500}, {-0.062500,0.437500,-0.062500,0.062500,-0.500000,0.062500},
{-0.037500,-1.237500,0.037500,0.037500,0.500000,-0.025000}, {-0.037500,1.237500,0.037500,0.037500,-0.500000,-0.025000},
} }
}, },
}) })
--Stalagmites --Stalagmites

View File

@ -7,27 +7,24 @@
-- Looked at code from: default -- Looked at code from: default
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
local random = math.random biome_lib:register_generate_plant(
{
abstract_dryplants.grow_grass = function(pos) surface = {
local right_here = {x=pos.x, y=pos.y+1, z=pos.z} "default:dirt_with_grass",
if minetest.get_node(right_here).name == "air" -- instead of check_air = true, "stoneage:grass_with_silex",
or minetest.get_node(right_here).name == "default:junglegrass" then "sumpf:peat",
minetest.swap_node(right_here, {name="default:grass_"..random(1,5)}) "sumpf:sumpf"
end },
end max_count = TALL_GRASS_PER_MAPBLOCK,
rarity = 101 - TALL_GRASS_RARITY,
biome_lib:register_generate_plant({ min_elevation = 1, -- above sea level
surface = { plantlife_limit = -0.9,
"default:dirt_with_grass", check_air = true,
"stoneage:grass_with_silex",
"sumpf:peat",
"sumpf:sumpf"
}, },
max_count = TALL_GRASS_PER_MAPBLOCK, { "default:grass_1",
rarity = 101 - TALL_GRASS_RARITY, "default:grass_2",
min_elevation = 1, -- above sea level "default:grass_3",
plantlife_limit = -0.9, "default:grass_4",
}, "default:grass_5"
abstract_dryplants.grow_grass }
) )

View File

@ -245,7 +245,7 @@ minetest.register_node(":flowers:sunflower", {
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
is_ground_content = true, is_ground_content = true,
groups = { dig_immediate=3, flora=1, flammable=3 }, groups = { dig_immediate=3, flora=1, flammable=3, attached_node=1 },
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
selection_box = box, selection_box = box,
collision_box = box, collision_box = box,

View File

@ -4,33 +4,47 @@
-- TWiGS -- TWiGS
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
local random = math.random local fakenode = {
name = "default:stone", -- could be anything that's guaranteed to exist at mapgen time, and isn't buildable_to
param1 = 0,
param2 = 0
}
abstract_trunks.place_twig = function(pos) abstract_trunks.place_twig = function(pos)
local twig_size = random(1,27) local twig_size = math.random(1,27)
local right_here = {x=pos.x , y=pos.y+1, z=pos.z } local right_here = {x=pos.x , y=pos.y+1, z=pos.z }
local north = {x=pos.x , y=pos.y+1, z=pos.z+1} local north = {x=pos.x , y=pos.y+1, z=pos.z+1}
local north_east = {x=pos.x+1, y=pos.y+1, z=pos.z+1} local north_east = {x=pos.x+1, y=pos.y+1, z=pos.z+1}
local east = {x=pos.x+1, y=pos.y+1, z=pos.z } local east = {x=pos.x+1, y=pos.y+1, z=pos.z }
local south_east = {x=pos.x+1, y=pos.y+1, z=pos.z-1} local south_east = {x=pos.x+1, y=pos.y+1, z=pos.z-1}
local south = {x=pos.x , y=pos.y+1, z=pos.z-1} local south = {x=pos.x , y=pos.y+1, z=pos.z-1}
local south_west = {x=pos.x-1, y=pos.y+1, z=pos.z-1} local south_west = {x=pos.x-1, y=pos.y+1, z=pos.z-1}
local west = {x=pos.x-1, y=pos.y+1, z=pos.z } local west = {x=pos.x-1, y=pos.y+1, z=pos.z }
local north_west = {x=pos.x-1, y=pos.y+1, z=pos.z+1} local north_west = {x=pos.x-1, y=pos.y+1, z=pos.z+1}
local node_here = minetest.get_node(right_here)
local node_north = minetest.get_node(north)
local node_n_e = minetest.get_node(north_east)
local node_east = minetest.get_node(east)
local node_s_e = minetest.get_node(south_east)
local node_south = minetest.get_node(south)
local node_s_w = minetest.get_node(south_west)
local node_west = minetest.get_node(west)
local node_n_w = minetest.get_node(north_west)
node_north = minetest.registered_nodes[node_north.name] and node_north or fakenode
node_n_e = minetest.registered_nodes[node_n_e.name] and node_n_e or fakenode
node_east = minetest.registered_nodes[node_east.name] and node_east or fakenode
node_s_e = minetest.registered_nodes[node_s_e.name] and node_s_e or fakenode
node_south = minetest.registered_nodes[node_south.name] and node_south or fakenode
node_s_w = minetest.registered_nodes[node_s_w.name] and node_s_w or fakenode
node_west = minetest.registered_nodes[node_west.name] and node_west or fakenode
node_n_w = minetest.registered_nodes[node_n_w.name] and node_n_w or fakenode
local node_here = minetest.get_node(right_here)
local node_north = minetest.get_node(north)
local node_n_e = minetest.get_node(north_east)
local node_east = minetest.get_node(east)
local node_s_e = minetest.get_node(south_east)
local node_south = minetest.get_node(south)
local node_s_w = minetest.get_node(south_west)
local node_west = minetest.get_node(west)
local node_n_w = minetest.get_node(north_west)
-- small twigs -- small twigs
if twig_size <= 16 then if twig_size <= 16 then
minetest.swap_node(right_here, {name="trunks:twig_"..random(1,4), param2=random(0,3)}) minetest.swap_node(right_here, {name="trunks:twig_"..math.random(1,4), param2=math.random(0,3)})
end end
-- big twigs -- big twigs
if Big_Twigs == true then if Big_Twigs == true then
@ -149,7 +163,7 @@ abstract_trunks.place_twig = function(pos)
end end
end end
elseif twig_size <= 25 then elseif twig_size <= 25 then
minetest.swap_node(right_here, {name="trunks:twig_"..random(12,13), param2=random(0,3)}) minetest.swap_node(right_here, {name="trunks:twig_"..math.random(12,13), param2=math.random(0,3)})
end end
end end
end end
@ -256,10 +270,10 @@ abstract_trunks.place_trunk = function(pos)
local MoD = TRuNKS[i][1] local MoD = TRuNKS[i][1]
local TRuNK = TRuNKS[i][2] local TRuNK = TRuNKS[i][2]
local NR = TRuNKS[i][3] local NR = TRuNKS[i][3]
local chance = random(1, 17) local chance = math.random(1, 17)
local length = random(3,5) local length = math.random(3,5)
if chance == NR then if chance == NR then
local trunk_type = random(1,3) local trunk_type = math.random(1,3)
if trunk_type == 1 then if trunk_type == 1 then
if minetest.get_modpath(MoD) ~= nil then if minetest.get_modpath(MoD) ~= nil then
minetest.swap_node(right_here, {name=MoD..":"..TRuNK}) minetest.swap_node(right_here, {name=MoD..":"..TRuNK})
@ -357,12 +371,13 @@ biome_lib:register_generate_plant({
if Moss_on_ground == true then if Moss_on_ground == true then
abstract_trunks.grow_moss_on_ground = function(pos) abstract_trunks.grow_moss_on_ground = function(pos)
local on_ground = {x=pos.x, y=pos.y+1, z=pos.z} local on_ground = {x=pos.x, y=pos.y+1, z=pos.z}
local moss_type = random(1,21) local moss_type = math.random(1,21)
local rot = math.random(0,3)
if moss_type == 1 then if moss_type == 1 then
minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=random(0,3)}) minetest.swap_node(on_ground, {name="trunks:moss_with_fungus_"..rot, param2=1})
else else
minetest.swap_node(on_ground, {name="trunks:moss", param2=random(0,3)}) minetest.swap_node(on_ground, {name="trunks:moss_plain_"..rot, param2=1})
end end
end end
@ -408,44 +423,49 @@ abstract_trunks.grow_moss_on_trunk = function(pos)
local node_under = minetest.get_node(undrneath) local node_under = minetest.get_node(undrneath)
--if minetest.get_item_group(node_under.name, "tree") < 1 then --if minetest.get_item_group(node_under.name, "tree") < 1 then
local moss_type = random(1,41) if minetest.registered_nodes[node_here.name].buildable_to then
if minetest.registered_nodes[node_here.name].buildable_to then -- instead of check_air = true, local moss_type = math.random(1,41)
local rot = math.random(0,3)
if moss_type == 1 then if moss_type == 1 then
minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=random(0,3) --[[1]]}) minetest.swap_node(on_ground, {name="trunks:moss_with_fungus_"..rot, param2=1})
elseif moss_type < 22 then elseif moss_type < 22 then
minetest.swap_node(on_ground, {name="trunks:moss", param2=random(0,3) --[[1]]}) minetest.swap_node(on_ground, {name="trunks:moss_plain_"..rot, param2=1})
end end
end end
local moss_type = random(1,31) -- cliche of more moss at north if minetest.registered_nodes[node_north.name].buildable_to then
if minetest.registered_nodes[node_north.name].buildable_to then -- instead of check_air = true, local moss_type = math.random(1,31) -- cliche of more moss at north
local rot = math.random(0,3)
if moss_type == 1 then if moss_type == 1 then
minetest.swap_node(at_side_n, {name="trunks:moss_fungus", param2=random(4,7)}) -- 5,4,6,7 minetest.swap_node(at_side_n, {name="trunks:moss_with_fungus_"..rot, param2=5})
elseif moss_type < 22 then elseif moss_type < 22 then
minetest.swap_node(at_side_n, {name="trunks:moss", param2=random(4,7)}) minetest.swap_node(at_side_n, {name="trunks:moss_plain_"..rot, param2=5})
end end
end end
local moss_type = random(1,41) if minetest.registered_nodes[node_east.name].buildable_to then
if minetest.registered_nodes[node_east.name].buildable_to then -- instead of check_air = true, local moss_type = math.random(1,41)
local rot = math.random(0,3)
if moss_type == 1 then if moss_type == 1 then
minetest.swap_node(at_side_e, {name="trunks:moss_fungus", param2=random(12,15)}) minetest.swap_node(at_side_e, {name="trunks:moss_with_fungus_"..rot, param2=3})
elseif moss_type < 22 then elseif moss_type < 22 then
minetest.swap_node(at_side_e, {name="trunks:moss", param2=random(12,15)}) minetest.swap_node(at_side_e, {name="trunks:moss_plain_"..rot, param2=3})
end end
end end
local moss_type = random(1,41) if minetest.registered_nodes[node_south.name].buildable_to then
if minetest.registered_nodes[node_south.name].buildable_to then -- instead of check_air = true, local moss_type = math.random(1,41)
local rot = math.random(0,3)
if moss_type == 1 then if moss_type == 1 then
minetest.swap_node(at_side_s, {name="trunks:moss_fungus", param2=random(8,11)}) minetest.swap_node(at_side_s, {name="trunks:moss_with_fungus_"..rot, param2=4})
elseif moss_type < 22 then elseif moss_type < 22 then
minetest.swap_node(at_side_s, {name="trunks:moss", param2=random(8,11)}) minetest.swap_node(at_side_s, {name="trunks:moss_plain_"..rot, param2=4})
end end
end end
local moss_type = random(1,41) if minetest.registered_nodes[node_west.name].buildable_to then
if minetest.registered_nodes[node_west.name].buildable_to then -- instead of check_air = true, local moss_type = math.random(1,41)
local rot = math.random(0,3)
if moss_type == 1 then if moss_type == 1 then
minetest.swap_node(at_side_w, {name="trunks:moss_fungus", param2=random(16,19)}) minetest.swap_node(at_side_w, {name="trunks:moss_with_fungus_"..rot, param2=2})
elseif moss_type < 22 then elseif moss_type < 22 then
minetest.swap_node(at_side_w, {name="trunks:moss", param2=random(16,19)}) minetest.swap_node(at_side_w, {name="trunks:moss_plain_"..rot, param2=2})
end end
end end
--end --end
@ -489,7 +509,7 @@ end
if Roots == true then -- see settings.txt if Roots == true then -- see settings.txt
abstract_trunks.grow_roots = function(pos) abstract_trunks.grow_roots = function(pos)
local twig_size = random(1,27) local twig_size = math.random(1,27)
local right_here = {x=pos.x , y=pos.y , z=pos.z } local right_here = {x=pos.x , y=pos.y , z=pos.z }
local below = {x=pos.x , y=pos.y-1, z=pos.z } local below = {x=pos.x , y=pos.y-1, z=pos.z }

View File

@ -66,42 +66,64 @@ end
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
-- MoSS -- MoSS
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
local flat_moss = {-1/2, -1/2, -1/2, 1/2, -15/32--[[<-flickers if smaller]], 1/2} -- wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
-- wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
-- wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375},
minetest.register_node("trunks:moss", { -- was local flat_moss = {-1/2, -1/2, -1/2, 1/2, -15/32, 1/2}
description = S("Moss"),
drawtype = "nodebox",--"signlike",
tiles = {"trunks_moss.png"},
inventory_image = "trunks_moss.png",
wield_image = "trunks_moss.png",
paramtype = "light",
paramtype2 = "facedir",--"wallmounted",
sunlight_propagates = true,
walkable = false,
node_box = {type = "fixed", fixed = flat_moss},
selection_box = {type = "fixed", fixed = flat_stick},--{type = "wallmounted"},
groups = {snappy = 3, flammable = 3, attached_node = 1 },
sounds = default.node_sound_leaves_defaults(),
})
-----------------------------------------------------------------------------------------------
-- MoSS & FuNGuS local cbox = {
----------------------------------------------------------------------------------------------- type = "wallmounted",
minetest.register_node("trunks:moss_fungus", { wall_top = {-1/2, 1/2, -1/2, 1/2, 15/32, 1/2},
description = S("Moss with Fungus"), wall_bottom = {-1/2, -1/2, -1/2, 1/2, -15/32, 1/2},
drawtype = "nodebox",--"signlike", wall_side = {-1/2, -1/2, -1/2, -15/32, 1/2, 1/2}
tiles = {"trunks_moss_fungus.png"}, }
inventory_image = "trunks_moss_fungus.png",
wield_image = "trunks_moss_fungus.png", for r = 0, 3 do
paramtype = "light", local xform = ""
paramtype2 = "facedir",--"wallmounted", if r > 0 then xform = "^[transformR"..r*90 end
sunlight_propagates = true,
walkable = false, minetest.register_node("trunks:moss_plain_"..r, {
node_box = {type = "fixed", fixed = flat_moss}, description = S("Moss"),
selection_box = {type = "fixed", fixed = flat_stick},--{type = "wallmounted"}, drawtype = "nodebox",
groups = {snappy = 3, flammable = 3, attached_node = 1 }, tiles = {"trunks_moss.png"..xform},
sounds = default.node_sound_leaves_defaults(), inventory_image = "trunks_moss.png",
}) wield_image = "trunks_moss.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
node_box = cbox,
buildable_to = true,
groups = {snappy = 3, flammable = 3, attached_node=1, not_in_creative_inventory = r},
sounds = default.node_sound_leaves_defaults(),
drop = "trunks:moss_plain_0",
})
-----------------------------------------------------------------------------------------------
-- MoSS & FuNGuS
-----------------------------------------------------------------------------------------------
minetest.register_node("trunks:moss_with_fungus_"..r, {
description = S("Moss with Fungus"),
drawtype = "nodebox",
tiles = {"trunks_moss_fungus.png"..xform},
inventory_image = "trunks_moss_fungus.png",
wield_image = "trunks_moss_fungus.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
node_box = cbox,
buildable_to = true,
groups = {snappy = 3, flammable = 3, attached_node=1, not_in_creative_inventory = r},
sounds = default.node_sound_leaves_defaults(),
drop = "trunks:moss_with_fungus_0",
})
end
minetest.register_alias("trunks:moss_plain", "trunks:moss_plain_0")
minetest.register_alias("trunks:moss_with_fungus", "trunks:moss_with_fungus_0")
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
-- TWiGS BLoCK -- TWiGS BLoCK
@ -362,7 +384,8 @@ for i in pairs(TRuNKS) do
snappy=1, snappy=1,
choppy=2, choppy=2,
oddly_breakable_by_hand=1, oddly_breakable_by_hand=1,
flammable=2--, flammable=2,
attached_node = 1
--not_in_creative_inventory=1 -- atm in inv for testing --not_in_creative_inventory=1 -- atm in inv for testing
}, },
--drop = "trunks:twig_1", -- not sure about this yet --drop = "trunks:twig_1", -- not sure about this yet
@ -377,3 +400,26 @@ end
end end
minetest.register_alias("trunks:pine_trunkroot", "trunks:pine_treeroot") minetest.register_alias("trunks:pine_trunkroot", "trunks:pine_treeroot")
-- convert moss to wallmounted mode so that attached_node works properly.
local fdirtowall = {
[0] = 1,
[1] = 5,
[2] = 4,
[3] = 3,
[4] = 2,
}
minetest.register_lbm({
name = "trunks:convert_moss_wallmounted",
label = "Convert moss to wallmounted mode",
run_at_every_load = true,
nodenames = {"trunks:moss", "trunks:moss_fungus"},
action = function(pos, node)
local basedir = math.floor(node.param2 / 4)
local rot = node.param2 % 4
local newname = node.name == "trunks:moss_fungus" and "trunks:moss_with_fungus" or "trunks:moss_plain"
minetest.set_node(pos, {name = newname.."_"..rot, param2 = fdirtowall[basedir] })
end
})

View File

@ -19,6 +19,11 @@ minetest.register_node("woodsoils:dirt_with_leaves_1", {
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4}, footstep = {name="default_grass_footstep", gain=0.4},
}), }),
soil = {
base = "woodsoils:dirt_with_leaves_1",
dry = "farming:soil",
wet = "farming:soil_wet"
}
}) })
minetest.register_node("woodsoils:dirt_with_leaves_2", { minetest.register_node("woodsoils:dirt_with_leaves_2", {
@ -37,6 +42,11 @@ minetest.register_node("woodsoils:dirt_with_leaves_2", {
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4}, footstep = {name="default_grass_footstep", gain=0.4},
}), }),
soil = {
base = "woodsoils:dirt_with_leaves_2",
dry = "farming:soil",
wet = "farming:soil_wet"
}
}) })
minetest.register_node("woodsoils:grass_with_leaves_1", { minetest.register_node("woodsoils:grass_with_leaves_1", {
@ -55,6 +65,11 @@ minetest.register_node("woodsoils:grass_with_leaves_1", {
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4}, footstep = {name="default_grass_footstep", gain=0.4},
}), }),
soil = {
base = "woodsoils:grass_with_leaves_1",
dry = "farming:soil",
wet = "farming:soil_wet"
}
}) })
minetest.register_node("woodsoils:grass_with_leaves_2", { minetest.register_node("woodsoils:grass_with_leaves_2", {
@ -73,6 +88,11 @@ minetest.register_node("woodsoils:grass_with_leaves_2", {
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4}, footstep = {name="default_grass_footstep", gain=0.4},
}), }),
soil = {
base = "woodsoils:grass_with_leaves_2",
dry = "farming:soil",
wet = "farming:soil_wet"
}
}) })
-- For compatibility with older stuff -- For compatibility with older stuff

View File

@ -42,7 +42,7 @@ minetest.register_node("youngtrees:youngtree2_middle",{
{-0.500000,0.125000,-0.500000,0.500000,0.500000,0.500000}, --NodeBox 3 {-0.500000,0.125000,-0.500000,0.500000,0.500000,0.500000}, --NodeBox 3
} }
}, },
groups = {snappy=3,flammable=2}, groups = {snappy=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
drop = 'trunks:twig_1' drop = 'trunks:twig_1'
}) })
@ -60,7 +60,7 @@ minetest.register_node("youngtrees:youngtree_top", {
type = "fixed", type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
}, },
groups = {snappy=3,flammable=2}, groups = {snappy=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
drop = 'trunks:twig_1' drop = 'trunks:twig_1'
}) })
@ -79,7 +79,7 @@ minetest.register_node("youngtrees:youngtree_middle", {
type = "fixed", type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
}, },
groups = {snappy=3,flammable=2}, groups = {snappy=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
drop = 'trunks:twig_1' drop = 'trunks:twig_1'
}) })
@ -99,7 +99,7 @@ minetest.register_node("youngtrees:youngtree_bottom", {
type = "fixed", type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
}, },
groups = {snappy=3,flammable=2}, groups = {snappy=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
drop = 'trunks:twig_1' drop = 'trunks:twig_1'
}) })