forked from mtcontrib/plantlife_modpack
replace biome_lib ABM's (#48)
* replace biome_lib ABM's * fix some params * remove 'group:flora' from poisonivy avoid list * fixes
This commit is contained in:
parent
3b7fa4e8ea
commit
2af1d996d2
@ -30,12 +30,19 @@ local modpath = minetest.get_modpath('bushes_classic')
|
|||||||
dofile(modpath..'/cooking.lua')
|
dofile(modpath..'/cooking.lua')
|
||||||
dofile(modpath..'/nodes.lua')
|
dofile(modpath..'/nodes.lua')
|
||||||
|
|
||||||
biome_lib.register_active_spawner({
|
local spawn_plants = bushes_classic.spawn_list
|
||||||
spawn_delay = 3600,
|
|
||||||
spawn_plants = bushes_classic.spawn_list,
|
local function get_biome_data(pos, perlin_fertile)
|
||||||
avoid_radius = 10,
|
local fertility = perlin_fertile:get_2d({x=pos.x, y=pos.z})
|
||||||
spawn_chance = 100,
|
|
||||||
spawn_surfaces = {
|
local data = minetest.get_biome_data(pos)
|
||||||
|
-- Original values this method returned were +1 (lowest) to -1 (highest)
|
||||||
|
-- so we need to convert the 0-100 range from get_biome_data() to that.
|
||||||
|
return fertility, 1 - (data.heat / 100 * 2), 1 - (data.humidity / 100 * 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {
|
||||||
"default:dirt_with_grass",
|
"default:dirt_with_grass",
|
||||||
"woodsoils:dirt_with_leaves_1",
|
"woodsoils:dirt_with_leaves_1",
|
||||||
"woodsoils:grass_with_leaves_1",
|
"woodsoils:grass_with_leaves_1",
|
||||||
@ -43,14 +50,31 @@ biome_lib.register_active_spawner({
|
|||||||
"farming:soil",
|
"farming:soil",
|
||||||
"farming:soil_wet"
|
"farming:soil_wet"
|
||||||
},
|
},
|
||||||
avoid_nodes = {"group:bush"},
|
interval = 3600,
|
||||||
seed_diff = 545342534, -- chosen by a fair mashing of the keyboard - guaranteed to be random :P
|
chance = 100,
|
||||||
plantlife_limit = -0.1,
|
label = "[bushes_classic] spawn bushes",
|
||||||
light_min = 10,
|
min_y = -16,
|
||||||
temp_min = 0.15, -- approx 20C
|
max_y = 48,
|
||||||
temp_max = -0.15, -- approx 35C
|
action = function(pos, node)
|
||||||
humidity_min = 0, -- 50% RH
|
local p_top = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
humidity_max = -1, -- 100% RH
|
local n_top = minetest.get_node_or_nil(p_top)
|
||||||
|
if not n_top or n_top.name ~= "air" then return end
|
||||||
|
|
||||||
|
local perlin_fertile_area = minetest.get_perlin(545342534, 3, 0.6, 100)
|
||||||
|
|
||||||
|
local fertility, temperature, humidity = get_biome_data(pos, perlin_fertile_area)
|
||||||
|
|
||||||
|
local pos_biome_ok = fertility > -0.1 and temperature <= 0.15 and temperature >= -0.15 and humidity <= 0 and humidity >= -1
|
||||||
|
if not pos_biome_ok then return end
|
||||||
|
|
||||||
|
if minetest.find_node_near(p_top, 10 + math.random(-1.5,2), {"group:bush"}) then
|
||||||
|
return -- Nodes to avoid are nearby
|
||||||
|
end
|
||||||
|
|
||||||
|
local plant_to_spawn = spawn_plants[math.random(1, #spawn_plants)]
|
||||||
|
|
||||||
|
minetest.swap_node(p_top, {name = plant_to_spawn, param2 = 0})
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_alias("bushes:basket_pies", "bushes:basket_strawberry")
|
minetest.register_alias("bushes:basket_pies", "bushes:basket_strawberry")
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
name = bushes_classic
|
name = bushes_classic
|
||||||
depends = biome_lib
|
|
||||||
optional_depends = farming, farming_plus
|
optional_depends = farming, farming_plus
|
||||||
|
@ -75,13 +75,10 @@ create_nodes()
|
|||||||
-- Spawning
|
-- Spawning
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
if abstract_ferns.config.enable_horsetails_spawning == true then
|
if abstract_ferns.config.enable_horsetails_spawning == true then
|
||||||
biome_lib.register_active_spawner({
|
minetest.register_abm({
|
||||||
spawn_delay = 1200,
|
nodenames = {
|
||||||
spawn_plants = node_names,
|
|
||||||
spawn_chance = 400,
|
|
||||||
spawn_surfaces = {
|
|
||||||
"default:dirt_with_grass",
|
"default:dirt_with_grass",
|
||||||
"default:dirt_with_coniferous_litter", -- minetest >= 0.5
|
"default:dirt_with_coniferous_litter",
|
||||||
"default:desert_sand",
|
"default:desert_sand",
|
||||||
"default:sand",
|
"default:sand",
|
||||||
"dryplants:grass_short",
|
"dryplants:grass_short",
|
||||||
@ -89,13 +86,28 @@ if abstract_ferns.config.enable_horsetails_spawning == true then
|
|||||||
"default:mossycobble",
|
"default:mossycobble",
|
||||||
"default:gravel"
|
"default:gravel"
|
||||||
},
|
},
|
||||||
seed_diff = 329,
|
interval = 1200,
|
||||||
min_elevation = 1, -- above sea level
|
chance = 400,
|
||||||
near_nodes = {"default:water_source","default:river_water_source","default:gravel"},
|
label = "[ferns] spawn horsetails",
|
||||||
near_nodes_size = 2,
|
min_y = 1,
|
||||||
near_nodes_vertical = 1,
|
max_y = 48,
|
||||||
near_nodes_count = 1,
|
action = function(pos, node)
|
||||||
--random_facedir = { 0, 179 },
|
local p_top = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
|
local n_top = minetest.get_node_or_nil(p_top)
|
||||||
|
if not n_top or n_top.name ~= "air" then return end
|
||||||
|
|
||||||
|
local NEAR_DST = 2
|
||||||
|
if #minetest.find_nodes_in_area(
|
||||||
|
{x=pos.x-NEAR_DST, y=pos.y-1, z=pos.z-NEAR_DST},
|
||||||
|
{x=pos.x+NEAR_DST, y=pos.y+1, z=pos.z+NEAR_DST},
|
||||||
|
{"default:water_source","default:river_water_source","default:gravel"}
|
||||||
|
) < 1 then return
|
||||||
|
end
|
||||||
|
|
||||||
|
local plant_to_spawn = node_names[math.random(1, #node_names)]
|
||||||
|
|
||||||
|
minetest.swap_node(p_top, {name = plant_to_spawn, param2 = 0})
|
||||||
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ pl_seaweed = {}
|
|||||||
local seaweed_max_count = tonumber(minetest.settings:get("pl_seaweed_max_count")) or 320
|
local seaweed_max_count = tonumber(minetest.settings:get("pl_seaweed_max_count")) or 320
|
||||||
local seaweed_rarity = tonumber(minetest.settings:get("pl_seaweed_rarity")) or 33
|
local seaweed_rarity = tonumber(minetest.settings:get("pl_seaweed_rarity")) or 33
|
||||||
|
|
||||||
|
local function get_ndef(name)
|
||||||
|
return minetest.registered_nodes[name] or {}
|
||||||
|
end
|
||||||
|
|
||||||
local algae_list = { {nil}, {2}, {3}, {4} }
|
local algae_list = { {nil}, {2}, {3}, {4} }
|
||||||
|
|
||||||
@ -59,22 +62,21 @@ for i in ipairs(algae_list) do
|
|||||||
local under_node = minetest.get_node(pt.under)
|
local under_node = minetest.get_node(pt.under)
|
||||||
local above_node = minetest.get_node(pt.above)
|
local above_node = minetest.get_node(pt.above)
|
||||||
local top_node = minetest.get_node(top_pos)
|
local top_node = minetest.get_node(top_pos)
|
||||||
|
if get_ndef(under_node.name)["buildable_to"] then
|
||||||
if biome_lib.get_nodedef_field(under_node.name, "buildable_to") then
|
|
||||||
if under_node.name ~= "default:water_source" then
|
if under_node.name ~= "default:water_source" then
|
||||||
place_pos = pt.under
|
place_pos = pt.under
|
||||||
elseif top_node.name ~= "default:water_source"
|
elseif top_node.name ~= "default:water_source" and get_ndef(top_node.name)["buildable_to"] then
|
||||||
and biome_lib.get_nodedef_field(top_node.name, "buildable_to") then
|
|
||||||
place_pos = top_pos
|
place_pos = top_pos
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
elseif biome_lib.get_nodedef_field(above_node.name, "buildable_to") then
|
elseif get_ndef(above_node.name)["buildable_to"] then
|
||||||
place_pos = pt.above
|
place_pos = pt.above
|
||||||
end
|
end
|
||||||
if not place_pos then return end -- something went wrong :P
|
if not place_pos then return end -- something went wrong :P
|
||||||
|
|
||||||
if not minetest.is_protected(place_pos, placer:get_player_name()) then
|
local pname = placer:get_player_name()
|
||||||
|
if not minetest.is_protected(place_pos, pname) then
|
||||||
|
|
||||||
local nodename = "default:cobble" -- :D
|
local nodename = "default:cobble" -- :D
|
||||||
|
|
||||||
@ -96,7 +98,7 @@ for i in ipairs(algae_list) do
|
|||||||
minetest.swap_node(place_pos, {name = "flowers:seaweed", param2 = fdir})
|
minetest.swap_node(place_pos, {name = "flowers:seaweed", param2 = fdir})
|
||||||
end
|
end
|
||||||
|
|
||||||
if not biome_lib.expect_infinite_stacks then
|
if not minetest.is_creative_enabled(pname) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -6,6 +6,9 @@ pl_waterlilies = {}
|
|||||||
local lilies_max_count = tonumber(minetest.settings:get("pl_waterlilies_max_count")) or 320
|
local lilies_max_count = tonumber(minetest.settings:get("pl_waterlilies_max_count")) or 320
|
||||||
local lilies_rarity = tonumber(minetest.settings:get("pl_waterlilies_rarity")) or 33
|
local lilies_rarity = tonumber(minetest.settings:get("pl_waterlilies_rarity")) or 33
|
||||||
|
|
||||||
|
local function get_ndef(name)
|
||||||
|
return minetest.registered_nodes[name] or {}
|
||||||
|
end
|
||||||
|
|
||||||
local lilies_list = {
|
local lilies_list = {
|
||||||
{ nil , nil , 1 },
|
{ nil , nil , 1 },
|
||||||
@ -72,20 +75,20 @@ for i in ipairs(lilies_list) do
|
|||||||
local above_node = minetest.get_node(pt.above)
|
local above_node = minetest.get_node(pt.above)
|
||||||
local top_node = minetest.get_node(top_pos)
|
local top_node = minetest.get_node(top_pos)
|
||||||
|
|
||||||
if biome_lib.get_nodedef_field(under_node.name, "buildable_to") then
|
if get_ndef(under_node.name)["buildable_to"] then
|
||||||
if under_node.name ~= "default:water_source" then
|
if under_node.name ~= "default:water_source" then
|
||||||
place_pos = pt.under
|
place_pos = pt.under
|
||||||
elseif top_node.name ~= "default:water_source"
|
elseif top_node.name ~= "default:water_source" and get_ndef(top_node.name)["buildable_to"] then
|
||||||
and biome_lib.get_nodedef_field(top_node.name, "buildable_to") then
|
|
||||||
place_pos = top_pos
|
place_pos = top_pos
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
elseif biome_lib.get_nodedef_field(above_node.name, "buildable_to") then
|
elseif get_ndef(above_node.name)["buildable_to"] then
|
||||||
place_pos = pt.above
|
place_pos = pt.above
|
||||||
end
|
end
|
||||||
|
|
||||||
if place_pos and not minetest.is_protected(place_pos, placer:get_player_name()) then
|
local pname = placer:get_player_name()
|
||||||
|
if place_pos and not minetest.is_protected(place_pos, pname) then
|
||||||
|
|
||||||
local nodename = "default:cobble" -- if this block appears, something went....wrong :-)
|
local nodename = "default:cobble" -- if this block appears, something went....wrong :-)
|
||||||
|
|
||||||
@ -114,7 +117,7 @@ for i in ipairs(lilies_list) do
|
|||||||
minetest.swap_node(place_pos, {name = "flowers:waterlily", param2 = fdir})
|
minetest.swap_node(place_pos, {name = "flowers:waterlily", param2 = fdir})
|
||||||
end
|
end
|
||||||
|
|
||||||
if not biome_lib.expect_infinite_stacks then
|
if not minetest.is_creative_enabled(pname) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -3,11 +3,6 @@
|
|||||||
-- support for i18n
|
-- support for i18n
|
||||||
local S = minetest.get_translator("poisonivy")
|
local S = minetest.get_translator("poisonivy")
|
||||||
|
|
||||||
local SPAWN_DELAY = 1000
|
|
||||||
local SPAWN_CHANCE = 200
|
|
||||||
local GROW_DELAY = 500
|
|
||||||
local GROW_CHANCE = 30
|
|
||||||
local poisonivy_seed_diff = 339
|
|
||||||
local walls_list = {
|
local walls_list = {
|
||||||
"default:dirt",
|
"default:dirt",
|
||||||
"default:dirt_with_grass",
|
"default:dirt_with_grass",
|
||||||
@ -69,33 +64,75 @@ minetest.register_node('poisonivy:climbing', {
|
|||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
biome_lib.register_active_spawner({
|
local function find_adjacent_wall(pos, verticals, randomflag)
|
||||||
spawn_delay = SPAWN_DELAY,
|
local verts = dump(verticals)
|
||||||
spawn_plants = {"poisonivy:seedling"},
|
|
||||||
avoid_radius = 10,
|
if string.find(verts, minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z }).name) then return 3 end
|
||||||
spawn_chance = SPAWN_CHANCE/10,
|
if string.find(verts, minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z }).name) then return 2 end
|
||||||
spawn_surfaces = {"default:dirt_with_grass"},
|
if string.find(verts, minetest.get_node({x=pos.x , y=pos.y, z=pos.z-1}).name) then return 5 end
|
||||||
avoid_nodes = {"group:poisonivy", "group:flower", "group:flora"},
|
if string.find(verts, minetest.get_node({x=pos.x , y=pos.y, z=pos.z+1}).name) then return 4 end
|
||||||
seed_diff = poisonivy_seed_diff,
|
|
||||||
light_min = 7,
|
return nil
|
||||||
alt_wallnode = "poisonivy:climbing",
|
end
|
||||||
verticals_list = walls_list
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"default:dirt_with_grass"},
|
||||||
|
interval = 1000,
|
||||||
|
chance = 20,
|
||||||
|
label = "[poisoninvy] spawn plants",
|
||||||
|
min_y = -16,
|
||||||
|
max_y = 48,
|
||||||
|
action = function(pos, node)
|
||||||
|
local p_top = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
|
local n_top = minetest.get_node_or_nil(p_top)
|
||||||
|
if not n_top or n_top.name ~= "air" then return end
|
||||||
|
|
||||||
|
local n_light = minetest.get_node_light(p_top)
|
||||||
|
if n_light < 7 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.find_node_near(p_top, 10 + math.random(-1.5,2), {"group:poisonivy", "group:flower"}) then
|
||||||
|
return -- Nodes to avoid are nearby
|
||||||
|
end
|
||||||
|
|
||||||
|
local walldir = find_adjacent_wall(p_top, walls_list)
|
||||||
|
if walldir then
|
||||||
|
minetest.swap_node(p_top, {name = "poisonivy:climbing", param2 = walldir})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.swap_node(p_top, {name = "poisonivy:seedling", param2 = 0})
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
biome_lib.update_plant({
|
minetest.register_abm({
|
||||||
grow_delay = SPAWN_DELAY,
|
nodenames = {"poisonivy:seedling"},
|
||||||
grow_chance = GROW_CHANCE,
|
interval = 1000,
|
||||||
grow_plant = "poisonivy:seedling",
|
chance = 30,
|
||||||
grow_result = "poisonivy:sproutling",
|
label = "grow poisonivy",
|
||||||
grow_nodes = {"default:dirt_with_grass"}
|
action = function(pos, node)
|
||||||
|
local p_top = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
|
local n_top = minetest.get_node(p_top)
|
||||||
|
|
||||||
|
if n_top.name == "air" then
|
||||||
|
minetest.swap_node(pos, {name = "poisonivy:sproutling"})
|
||||||
|
end
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
biome_lib.update_plant({
|
minetest.register_abm({
|
||||||
grow_delay = GROW_DELAY,
|
nodenames = {"poisonivy:climbing"},
|
||||||
grow_chance = GROW_CHANCE*2,
|
interval = 500,
|
||||||
grow_plant = "poisonivy:climbing",
|
chance = 60,
|
||||||
need_wall = true,
|
label = "grow climbing poisonivy",
|
||||||
grow_vertically = true,
|
action = function(pos, node)
|
||||||
verticals_list = walls_list,
|
local p_top = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
ground_nodes = {"default:dirt_with_grass"}
|
local n_top = minetest.get_node(p_top)
|
||||||
|
|
||||||
|
local walldir = find_adjacent_wall(p_top, walls_list)
|
||||||
|
if n_top.name == "air" and walldir then
|
||||||
|
minetest.swap_node(p_top, {name = "poisonivy:climbing", param2 = walldir})
|
||||||
|
end
|
||||||
|
end
|
||||||
})
|
})
|
@ -1,2 +1,2 @@
|
|||||||
name = poisonivy
|
name = poisonivy
|
||||||
depends = biome_lib
|
depends = default
|
||||||
|
Loading…
Reference in New Issue
Block a user