3 Commits

Author SHA1 Message Date
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
22 changed files with 185 additions and 214 deletions

View File

@ -6,8 +6,6 @@
-- (Leaf texture created by RealBadAngel or VanessaE)
-- Branch textures created by Neuromancer.
local random = math.random
-- support for i18n
local S = minetest.get_translator("bushes")
abstract_bushes = {}
@ -131,21 +129,32 @@ for i in pairs(BushLeafNode) do
end
abstract_bushes.grow_bush = function(pos)
local leaf_type = random(1,2)
for _, pos_dir in ipairs({
{ pos = {x=pos.x+1, y=pos.y+random(0,1), z=pos.z},
dir = 3},
{ pos = {x=pos.x-1, y=pos.y+random(0,1), z=pos.z},
dir = 1},
{ pos = {x=pos.x, y=pos.y+random(0,1), z=pos.z+1},
dir = 2},
{ pos = {x=pos.x, y=pos.y+random(0,1), z=pos.z-1},
dir = 0}
}) do
if random(1,10) > 5 then
abstract_bushes.grow_bush_node(pos_dir.pos, pos_dir.dir, leaf_type)
local leaf_type = math.random(1,2)
local bush_side_height = math.random(0,1)
local chance_of_bush_node_right = math.random(1,10)
if chance_of_bush_node_right> 5 then
local right_pos = {x=pos.x+1, y=pos.y+bush_side_height, z=pos.z}
abstract_bushes.grow_bush_node(right_pos,3,leaf_type)
end
local chance_of_bush_node_left = math.random(1,10)
if chance_of_bush_node_left> 5 then
bush_side_height = math.random(0,1)
local left_pos = {x=pos.x-1, y=pos.y+bush_side_height, z=pos.z}
abstract_bushes.grow_bush_node(left_pos,1,leaf_type)
end
local chance_of_bush_node_front = math.random(1,10)
if chance_of_bush_node_front> 5 then
bush_side_height = math.random(0,1)
local front_pos = {x=pos.x, y=pos.y+bush_side_height, z=pos.z+1}
abstract_bushes.grow_bush_node(front_pos,2,leaf_type)
end
local chance_of_bush_node_back = math.random(1,10)
if chance_of_bush_node_back> 5 then
bush_side_height = math.random(0,1)
local back_pos = {x=pos.x, y=pos.y+bush_side_height, z=pos.z-1}
abstract_bushes.grow_bush_node(back_pos,0,leaf_type)
end
abstract_bushes.grow_bush_node(pos,5,leaf_type)
end
@ -178,9 +187,11 @@ abstract_bushes.grow_bush_node = function(pos,dir, leaf_type)
minetest.swap_node(right_here, {name="bushes:bushbranches"..bush_branch_type , param2=dir})
--minetest.chat_send_all("leaf_type: (" .. leaf_type .. ")")
minetest.swap_node(above_right_here, {name="bushes:BushLeaves"..leaf_type})
if random(1,10) > 5 then
local chance_of_high_leaves = math.random(1,10)
if chance_of_high_leaves> 5 then
local two_above_right_here = {x=pos.x, y=pos.y+3, z=pos.z}
--minetest.chat_send_all("leaf_type: (" .. leaf_type .. ")")
minetest.swap_node({x=pos.x, y=pos.y+3, z=pos.z}, {name="bushes:BushLeaves"..leaf_type})
minetest.swap_node(two_above_right_here, {name="bushes:BushLeaves"..leaf_type})
end
end
end
@ -202,7 +213,8 @@ biome_lib:register_generate_plant({
)
abstract_bushes.grow_youngtree2 = function(pos)
abstract_bushes.grow_youngtree_node2(pos, random(4,5))
local height = math.random(4,5)
abstract_bushes.grow_youngtree_node2(pos,height)
end
abstract_bushes.grow_youngtree_node2 = function(pos, height)
@ -213,9 +225,9 @@ abstract_bushes.grow_youngtree_node2 = function(pos, height)
local two_above_right_here = {x=pos.x, y=pos.y+3, z=pos.z}
local three_above_right_here = {x=pos.x, y=pos.y+4, z=pos.z}
if height == 4 and
(minetest.get_node(right_here).name == "air" -- instead of check_air = true,
or minetest.get_node(right_here).name == "default:junglegrass") then
if minetest.get_node(right_here).name == "air" -- instead of check_air = true,
or minetest.get_node(right_here).name == "default:junglegrass" then
if height == 4 then
local two_above_right_here_south = {x=pos.x, y=pos.y+3, z=pos.z-1}
local three_above_right_here_south = {x=pos.x, y=pos.y+4, z=pos.z-1}
minetest.swap_node(right_here, {name="bushes:youngtree2_bottom"})
@ -225,6 +237,8 @@ abstract_bushes.grow_youngtree_node2 = function(pos, height)
minetest.swap_node(three_above_right_here, {name="bushes:BushLeaves1" })
minetest.swap_node(three_above_right_here_south, {name="bushes:BushLeaves1" })
end
end
end
@ -244,5 +258,3 @@ biome_lib:register_generate_plant({
)
--http://dev.minetest.net/Node_Drawtypes
minetest.log("action", "[bushes] loaded.")

View File

@ -4,8 +4,6 @@ local S = minetest.get_translator("bushes_classic")
plantlife_bushes = {}
-- TODO: add support for nodebreakers? those dig like mese picks
local random = math.random
plantlife_bushes.after_dig_node = function(pos, oldnode, oldmetadata, digger)
if not (digger and pos and oldnode) then
return
@ -65,7 +63,7 @@ plantlife_bushes.after_dig_node = function(pos, oldnode, oldmetadata, digger)
-- with a chance of 1/3, return 2 bushes
local amount
if random(1,3) == 1 then
if math.random(1,3) == 1 then
amount = "2"
else
amount = "1"
@ -77,7 +75,7 @@ plantlife_bushes.after_dig_node = function(pos, oldnode, oldmetadata, digger)
elseif groupcaps.choppy then
-- the amount of sticks may vary
local amount = random(4, 20)
local amount = math.random(4, 20)
-- return some sticks
harvested = "default:stick " .. amount
@ -138,7 +136,7 @@ minetest.register_abm({
local dirt = minetest.get_node(dirtpos)
local is_soil = minetest.get_item_group(dirt.name, "soil") or minetest.get_item_group(dirt.name, "potting_soil")
if is_soil and (dirt.name == "farming:soil_wet" or random(1,3) == 1) then
if is_soil and (dirt.name == "farming:soil_wet" or math.random(1,3) == 1) then
minetest.swap_node( pos, {name = "bushes:" .. bush_name .. "_bush"})
end
end

View File

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

View File

@ -1,55 +1,39 @@
--Map Generation Stuff
local random = math.random
local floor = math.floor
biome_lib:register_generate_plant(
{
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)
if maxp.y >= 2 and minp.y <= 0 then
-- Generate pebbles
local perlin1 = minetest.get_perlin(329, 3, 0.6, 100)
-- Assume X and Z lengths are equal
local divlen = 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 + floor((divx+0)*divlen)
local z0 = minp.z + floor((divz+0)*divlen)
local x1 = minp.x + floor((divx+1)*divlen)
local z1 = minp.z + floor((divz+1)*divlen)
-- Determine pebble amount from perlin noise
local pebble_amount = floor(perlin1:get2d({x=x0, y=z0}) ^ 2 * 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)
biome_lib:register_generate_plant(
{
surface = {
"default:desert_sand",
"default:desert_stone"
},
max_count = 50,
rarity = 0,
plantlife_limit = -1,
check_air = true,
random_facedir = {0, 3}
},
{
"cavestuff:desert_pebble_1",
"cavestuff:desert_pebble_2"
}
)

View File

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

View File

@ -1,8 +1,6 @@
-- support for i18n
local S = minetest.get_translator("cavestuff")
local random = math.random
--Rocks
local cbox = {
@ -22,7 +20,7 @@ minetest.register_node("cavestuff:pebble_1",{
collision_box = cbox,
on_place = function(itemstack, placer, pointed_thing)
-- place a random pebble node
local stack = ItemStack("cavestuff:pebble_"..random(1,2))
local stack = ItemStack("cavestuff:pebble_"..math.random(1,2))
local ret = minetest.item_place(stack, placer, pointed_thing)
return ItemStack("cavestuff:pebble_1 "..itemstack:get_count()-(1-ret:get_count()))
end,
@ -55,7 +53,7 @@ minetest.register_node("cavestuff:desert_pebble_1",{
collision_box = cbox,
on_place = function(itemstack, placer, pointed_thing)
-- place a random pebble node
local stack = ItemStack("cavestuff:desert_pebble_"..random(1,2))
local stack = ItemStack("cavestuff:desert_pebble_"..math.random(1,2))
local ret = minetest.item_place(stack, placer, pointed_thing)
return ItemStack("cavestuff:desert_pebble_1 "..itemstack:get_count()-(1-ret:get_count()))
end,
@ -99,7 +97,7 @@ minetest.register_node("cavestuff:stalactite_1",{
if minetest.get_node(pt.under).name=="default:stone"
and minetest.get_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}).name=="air"
and minetest.get_node({x=pt.under.x, y=pt.under.y-2, z=pt.under.z}).name=="air" then
minetest.swap_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}, {name="cavestuff:stalactite_"..random(1,3)})
minetest.swap_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}, {name="cavestuff:stalactite_"..math.random(1,3)})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end

View File

@ -11,11 +11,8 @@
-- support for i18n
local S = minetest.get_translator("dryplants")
local random = math.random
local sqrt = math.sqrt
abstract_dryplants.grow_juncus = function(pos)
local juncus_type = random(2,3)
local juncus_type = math.random(2,3)
local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
if minetest.get_node(right_here).name == "air" -- instead of check_air = true,
or minetest.get_node(right_here).name == "default:junglegrass" then
@ -30,7 +27,7 @@ end
minetest.register_node("dryplants:juncus", {
description = S("Juncus"),
drawtype = "plantlike",
visual_scale = sqrt(8),
visual_scale = math.sqrt(8),
paramtype = "light",
tiles = {"dryplants_juncus_03.png"},
inventory_image = "dryplants_juncus_inv.png",
@ -56,7 +53,7 @@ minetest.register_node("dryplants:juncus", {
return
end
local pos = pointed_thing.under
local juncus_type = random(2,3)
local juncus_type = math.random(2,3)
local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
if juncus_type == 2 then
minetest.swap_node(right_here, {name="dryplants:juncus_02"})
@ -72,7 +69,7 @@ minetest.register_node("dryplants:juncus", {
minetest.register_node("dryplants:juncus_02", {
description = S("Juncus"),
drawtype = "plantlike",
visual_scale = sqrt(8),
visual_scale = math.sqrt(8),
paramtype = "light",
tiles = {"dryplants_juncus_02.png"},
walkable = false,

View File

@ -8,7 +8,8 @@
-----------------------------------------------------------------------------------------------
abstract_dryplants.grow_grass_variation = function(pos)
minetest.swap_node(pos, {name="dryplants:grass_short"})
local right_here = {x=pos.x, y=pos.y, z=pos.z}
minetest.swap_node(right_here, {name="dryplants:grass_short"})
end
biome_lib:register_generate_plant({

View File

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

View File

@ -20,16 +20,13 @@
-- support for i18n
local S = minetest.get_translator("dryplants")
local random = math.random
local sqrt = math.sqrt
-----------------------------------------------------------------------------------------------
-- REEDMACE SHAPES
-----------------------------------------------------------------------------------------------
abstract_dryplants.grow_reedmace = function(pos)
local size = random(1,3)
local spikes = random(1,3)
local size = math.random(1,3)
local spikes = math.random(1,3)
local pos_01 = {x = pos.x, y = pos.y + 1, z = pos.z}
local pos_02 = {x = pos.x, y = pos.y + 2, z = pos.z}
local pos_03 = {x = pos.x, y = pos.y + 3, z = pos.z}
@ -54,8 +51,8 @@ abstract_dryplants.grow_reedmace = function(pos)
end
abstract_dryplants.grow_reedmace_water = function(pos)
local size = random(1,3)
local spikes = random(1,3)
local size = math.random(1,3)
local spikes = math.random(1,3)
local pos_01 = {x = pos.x, y = pos.y + 1, z = pos.z}
local pos_02 = {x = pos.x, y = pos.y + 2, z = pos.z}
local pos_03 = {x = pos.x, y = pos.y + 3, z = pos.z}
@ -130,7 +127,7 @@ minetest.register_node("dryplants:reedmace_top", {
minetest.register_node("dryplants:reedmace_height_2", {
description = S("Reedmace, height: 2"),
drawtype = "plantlike",
visual_scale = sqrt(8),
visual_scale = math.sqrt(8),
paramtype = "light",
tiles = {"dryplants_reedmace_height_2.png"},
inventory_image = "dryplants_reedmace_top.png",
@ -153,7 +150,7 @@ minetest.register_node("dryplants:reedmace_height_2", {
minetest.register_node("dryplants:reedmace_height_3", {
description = S("Reedmace, height: 3"),
drawtype = "plantlike",
visual_scale = sqrt(8),
visual_scale = math.sqrt(8),
paramtype = "light",
tiles = {"dryplants_reedmace_height_3.png"},
inventory_image = "dryplants_reedmace_top.png",
@ -176,7 +173,7 @@ minetest.register_node("dryplants:reedmace_height_3", {
minetest.register_node("dryplants:reedmace_height_3_spikes", {
description = S("Reedmace, height: 3 & Spikes"),
drawtype = "plantlike",
visual_scale = sqrt(8),
visual_scale = math.sqrt(8),
paramtype = "light",
tiles = {"dryplants_reedmace_height_3_spikes.png"},
inventory_image = "dryplants_reedmace_top.png",

View File

@ -48,5 +48,5 @@ HAY_DRYING_TIME = 3600 -- seconds
REED_WILL_DRY = false -- wet reed nodes will become dry reed nodes
REED_DRYING_TIME = 3600 -- seconds
AUTO_ROOF_CORNER = false
AUTO_ROOF_CORNER = true

View File

@ -252,14 +252,11 @@ minetest.register_node("ferns:fern_trunk_big", {
},
groups = {tree=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
sounds = default.node_sound_wood_defaults(),
after_dig_node = function(pos, node, metadata, digger)
if digger == nil then return end
local np = {x=pos.x,y=pos.y+1,z=pos.z}
local nn = minetest.get_node(np)
if nn.name == "ferns:fern_trunk_big" or
nn.name == "ferns:fern_trunk_big_top"
then
minetest.node_dig(np, nn, digger)
after_destruct = function(pos,oldnode)
local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if node.name == "ferns:fern_trunk_big" or node.name == "ferns:fern_trunk_big_top" then
minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z})
minetest.add_item(pos,"ferns:fern_trunk_big")
end
end,
})

View File

@ -11,8 +11,6 @@ local S = minetest.get_translator("ferns")
assert(abstract_ferns.config.enable_treefern == true)
local random = math.random
abstract_ferns.grow_tree_fern = function(pos)
local pos_aux = {x = pos.x, y = pos.y + 1, z = pos.z}
@ -22,12 +20,12 @@ abstract_ferns.grow_tree_fern = function(pos)
return
end
local size = random(1, 4) + random(1, 4)
local size = math.random(1, 4) + math.random(1, 4)
if (size > 5) then
size = 10 - size
end
size = size + 1
local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[random(1, 2)]
local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)]
local i = 1
local brk = false
@ -140,8 +138,12 @@ minetest.register_node("ferns:fern_trunk", {
},
groups = {tree=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
sounds = default.node_sound_wood_defaults(),
after_dig_node = function(pos, node, metadata, digger)
default.dig_up(pos, node, digger)
after_destruct = function(pos,oldnode)
local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if node.name == "ferns:fern_trunk" then
minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z})
minetest.add_item(pos,"ferns:fern_trunk")
end
end,
})

View File

@ -4,8 +4,6 @@ local S = minetest.get_translator("flowers_plus")
-- This file supplies a few additional plants and some related crafts
-- for the plantlife modpack. Last revision: 2013-04-24
local random = math.random
flowers_plus = {}
local SPAWN_DELAY = 1000
@ -99,7 +97,7 @@ for i in ipairs(lilies_list) do
if not keys["sneak"] then
local node = minetest.get_node(pt.under)
local waterlily = random(1,8)
local waterlily = math.random(1,8)
if waterlily == 1 then
nodename = "flowers:waterlily"
elseif waterlily == 2 then
@ -117,7 +115,7 @@ for i in ipairs(lilies_list) do
elseif waterlily == 8 then
nodename = "flowers:waterlily_s4"
end
minetest.swap_node(place_pos, {name = nodename, param2 = random(0,3) })
minetest.swap_node(place_pos, {name = nodename, param2 = math.random(0,3) })
else
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.swap_node(place_pos, {name = "flowers:waterlily", param2 = fdir})
@ -199,7 +197,7 @@ for i in ipairs(algae_list) do
if not keys["sneak"] then
--local node = minetest.get_node(pt.under)
local seaweed = random(1,4)
local seaweed = math.random(1,4)
if seaweed == 1 then
nodename = "flowers:seaweed"
elseif seaweed == 2 then
@ -209,7 +207,7 @@ for i in ipairs(algae_list) do
elseif seaweed == 4 then
nodename = "flowers:seaweed_4"
end
minetest.swap_node(place_pos, {name = nodename, param2 = random(0,3) })
minetest.swap_node(place_pos, {name = nodename, param2 = math.random(0,3) })
else
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.swap_node(place_pos, {name = "flowers:seaweed", param2 = fdir})
@ -287,7 +285,7 @@ minetest.register_alias( "along_shore:seaweed_4" , "flowers:seaweed_4" )
flowers_plus.grow_waterlily = function(pos)
local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
for i in ipairs(lilies_list) do
local chance = random(1,8)
local chance = math.random(1,8)
local ext = ""
local num = lilies_list[i][3]
@ -296,7 +294,7 @@ flowers_plus.grow_waterlily = function(pos)
end
if chance == num then
minetest.swap_node(right_here, {name="flowers:waterlily"..ext, param2=random(0,3)})
minetest.swap_node(right_here, {name="flowers:waterlily"..ext, param2=math.random(0,3)})
end
end
end
@ -320,7 +318,7 @@ biome_lib:register_generate_plant({
flowers_plus.grow_seaweed = function(pos)
local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
minetest.swap_node(right_here, {name="along_shore:seaweed_"..random(1,4), param2=random(1,3)})
minetest.swap_node(right_here, {name="along_shore:seaweed_"..math.random(1,4), param2=math.random(1,3)})
end
biome_lib:register_generate_plant({

View File

@ -1,5 +1,3 @@
minetest.register_alias("junglegrass:shortest", "air")
minetest.register_alias("junglegrass:short", "air")
minetest.register_alias("junglegrass:medium", "air")
minetest.log("action", "[junglegrass] loaded.")

View File

@ -2,8 +2,6 @@
local S = minetest.get_translator("nature_classic")
-- Blossoms and such
local random = math.random
local function spawn_apple_under(pos)
local below = {
x = pos.x,
@ -48,7 +46,7 @@ minetest.register_abm({
chance = nature.leaves_blossom_chance,
action = function(pos, node, active_object_count, active_object_count_wider)
if random(nature.leaves_blossom_chance) == 1 then
if math.random(nature.leaves_blossom_chance) == 1 then
nature.enqueue_node(pos, node, nature.blossom_node)
end
end
@ -63,7 +61,7 @@ minetest.register_abm({
chance = nature.blossom_leaves_chance,
action = function(pos, node, active_object_count, active_object_count_wider)
if random(nature.blossom_leaves_chance) == 1 then
if math.random(nature.blossom_leaves_chance) == 1 then
nature.enqueue_node(pos, node, nature.blossom_leaves)
end
end
@ -78,7 +76,7 @@ minetest.register_abm({
chance = nature.apple_chance,
action = function(pos, node, active_object_count, active_object_count_wider)
if random(4) == 1 and nature.dtime < 0.2 and not minetest.find_node_near(pos, nature.apple_spread, { "default:apple" }) then
if math.random(4) == 1 and nature.dtime < 0.2 and not minetest.find_node_near(pos, nature.apple_spread, { "default:apple" }) then
spawn_apple_under(pos)
end
end

View File

@ -47,4 +47,4 @@ dofile(minetest.get_modpath(current_mod_name) .. "/config.lua")
dofile(minetest.get_modpath(current_mod_name) .. "/global_function.lua")
dofile(minetest.get_modpath(current_mod_name) .. "/blossom.lua")
minetest.log("action", S("[Nature Classic] loaded!"))
minetest.log("info", S("[Nature Classic] loaded!"))

View File

@ -4,10 +4,8 @@
-- TWiGS
-----------------------------------------------------------------------------------------------
local random = math.random
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 north = {x=pos.x , y=pos.y+1, z=pos.z+1}
@ -30,7 +28,7 @@ abstract_trunks.place_twig = function(pos)
local node_n_w = minetest.get_node(north_west)
-- small twigs
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
-- big twigs
if Big_Twigs == true then
@ -149,7 +147,7 @@ abstract_trunks.place_twig = function(pos)
end
end
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
@ -256,10 +254,10 @@ abstract_trunks.place_trunk = function(pos)
local MoD = TRuNKS[i][1]
local TRuNK = TRuNKS[i][2]
local NR = TRuNKS[i][3]
local chance = random(1, 17)
local length = random(3,5)
local chance = math.random(1, 17)
local length = math.random(3,5)
if chance == NR then
local trunk_type = random(1,3)
local trunk_type = math.random(1,3)
if trunk_type == 1 then
if minetest.get_modpath(MoD) ~= nil then
minetest.swap_node(right_here, {name=MoD..":"..TRuNK})
@ -357,12 +355,12 @@ biome_lib:register_generate_plant({
if Moss_on_ground == true then
abstract_trunks.grow_moss_on_ground = function(pos)
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)
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_fungus", param2=math.random(0,3)})
else
minetest.swap_node(on_ground, {name="trunks:moss", param2=random(0,3)})
minetest.swap_node(on_ground, {name="trunks:moss", param2=math.random(0,3)})
end
end
@ -408,44 +406,44 @@ abstract_trunks.grow_moss_on_trunk = function(pos)
local node_under = minetest.get_node(undrneath)
--if minetest.get_item_group(node_under.name, "tree") < 1 then
local moss_type = random(1,41)
local moss_type = math.random(1,41)
if minetest.registered_nodes[node_here.name].buildable_to then -- instead of check_air = true,
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_fungus", param2=math.random(0,3) --[[1]]})
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", param2=math.random(0,3) --[[1]]})
end
end
local moss_type = random(1,31) -- cliche of more moss at north
local moss_type = math.random(1,31) -- cliche of more moss at north
if minetest.registered_nodes[node_north.name].buildable_to then -- instead of check_air = true,
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_fungus", param2=math.random(4,7)}) -- 5,4,6,7
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", param2=math.random(4,7)})
end
end
local moss_type = random(1,41)
local moss_type = math.random(1,41)
if minetest.registered_nodes[node_east.name].buildable_to then -- instead of check_air = true,
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_fungus", param2=math.random(12,15)})
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", param2=math.random(12,15)})
end
end
local moss_type = random(1,41)
local moss_type = math.random(1,41)
if minetest.registered_nodes[node_south.name].buildable_to then -- instead of check_air = true,
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_fungus", param2=math.random(8,11)})
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", param2=math.random(8,11)})
end
end
local moss_type = random(1,41)
local moss_type = math.random(1,41)
if minetest.registered_nodes[node_west.name].buildable_to then -- instead of check_air = true,
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_fungus", param2=math.random(16,19)})
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", param2=math.random(16,19)})
end
end
--end
@ -489,7 +487,7 @@ end
if Roots == true then -- see settings.txt
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 below = {x=pos.x , y=pos.y-1, z=pos.z }

View File

@ -1,8 +1,6 @@
-- Code by Mossmanikin & Neuromancer
-- support for i18n
local S = minetest.get_translator("trunks")
local random = math.random
-----------------------------------------------------------------------------------------------
-- TWiGS
-----------------------------------------------------------------------------------------------
@ -58,6 +56,7 @@ for i in pairs(NoDe) do
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
end,
})
@ -80,7 +79,7 @@ minetest.register_node("trunks:moss", {
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 },
groups = {snappy = 3, flammable = 3 },
sounds = default.node_sound_leaves_defaults(),
})
@ -99,7 +98,7 @@ minetest.register_node("trunks:moss_fungus", {
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 },
groups = {snappy = 3, flammable = 3 },
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -64,7 +64,7 @@ Moss_on_trunk_Max_Count = 640 -- absolute maximum number in an area of 80x80x80
Moss_on_trunk_Rarity = 24 -- larger values makes moss more rare (100 means chance of 0 %)
Auto_Roof_Corner = false -- behavior is similar (not the same!) to the one of minecraft stairs
Auto_Roof_Corner = true -- behavior is similar (not the same!) to the one of minecraft stairs
Roots = true

View File

@ -18,8 +18,6 @@ minetest.register_craftitem("vines:vines", {
-- FUNCTIONS
local random = math.random
local function dig_down(pos, node, digger)
if digger == nil then return end
@ -82,7 +80,7 @@ vines.register_vine = function( name, defs, biome )
local timer = minetest.get_node_timer(pos)
timer:start(random(5, 10))
timer:start(math.random(5, 10))
end,
on_timer = function(pos)
@ -93,7 +91,7 @@ vines.register_vine = function( name, defs, biome )
if bottom_node.name == "air" then
if not random(defs.average_length) == 1 then
if not math.random(defs.average_length) == 1 then
minetest.set_node(pos, {
name = vine_name_middle, param2 = node.param2})
@ -103,7 +101,7 @@ vines.register_vine = function( name, defs, biome )
local timer = minetest.get_node_timer(bottom_node)
timer:start(random(5, 10))
timer:start(math.random(5, 10))
end
end
end,

View File

@ -1,8 +1,6 @@
-- support for i18n
local S = minetest.get_translator("youngtrees")
local random = math.random
abstract_youngtrees = {}
minetest.register_node("youngtrees:bamboo", {
@ -106,7 +104,8 @@ minetest.register_node("youngtrees:youngtree_bottom", {
abstract_youngtrees.grow_youngtree = function(pos)
abstract_youngtrees.grow_youngtree_node(pos, random(1,3))
local height = math.random(1,3)
abstract_youngtrees.grow_youngtree_node(pos,height)
end
abstract_youngtrees.grow_youngtree_node = function(pos, height)
@ -148,5 +147,3 @@ biome_lib:register_generate_plant({
},
abstract_youngtrees.grow_youngtree
)
minetest.log("action", "[youngtrees] loaded.")