forked from mtcontrib/plantlife_modpack
Remove biome_lib dep from dryplants (#63)
This commit is contained in:
@ -1,13 +1,3 @@
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- Grasses - Reedmace 0.1.1
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- by Mossmanikin
|
||||
-- textures & ideas partly by Neuromancer
|
||||
|
||||
-- Contains code from: biome_lib
|
||||
-- Looked at code from: default, trees
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
||||
-- NOTES (from wikipedia, some of this might get implemented)
|
||||
-- rhizomes are edible
|
||||
-- outer portion of young plants can be peeled and the heart can be eaten raw or boiled and eaten like asparagus
|
||||
@ -24,14 +14,16 @@ local S = minetest.get_translator("dryplants")
|
||||
-- REEDMACE SHAPES
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
||||
abstract_dryplants.grow_reedmace = function(pos)
|
||||
local function grow_reedmace(pos)
|
||||
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}
|
||||
if minetest.get_node(pos_01).name == "air" -- bug fix
|
||||
or minetest.get_node(pos_01).name == "dryplants:reedmace_sapling" then
|
||||
|
||||
local nodename = minetest.get_node(pos_01).name
|
||||
if nodename == "air" -- bug fix
|
||||
or nodename == "dryplants:reedmace_sapling" then
|
||||
if minetest.get_node(pos_02).name ~= "air" then
|
||||
minetest.swap_node(pos_01, {name="dryplants:reedmace_top"})
|
||||
elseif minetest.get_node(pos_03).name ~= "air" then
|
||||
@ -50,14 +42,16 @@ abstract_dryplants.grow_reedmace = function(pos)
|
||||
end
|
||||
end
|
||||
|
||||
abstract_dryplants.grow_reedmace_water = function(pos)
|
||||
local function grow_reedmace_water(pos)
|
||||
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}
|
||||
local pos_04 = {x = pos.x, y = pos.y + 4, z = pos.z}
|
||||
|
||||
minetest.add_entity(pos_01, "dryplants:reedmace_water_entity")
|
||||
|
||||
if minetest.get_node(pos_02).name == "air" then -- bug fix
|
||||
if minetest.get_node(pos_03).name ~= "air" then
|
||||
minetest.swap_node(pos_02, {name="dryplants:reedmace_top"})
|
||||
@ -284,11 +278,11 @@ minetest.register_abm({
|
||||
or string.find(minetest.get_node({x = pos.x - 1, y = pos.y, z = pos.z }).name, "default:water")
|
||||
or string.find(minetest.get_node({x = pos.x, y = pos.y, z = pos.z - 1}).name, "default:water") then
|
||||
if minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air" then
|
||||
abstract_dryplants.grow_reedmace_water({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
grow_reedmace_water({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
end
|
||||
minetest.swap_node({x=pos.x, y=pos.y, z=pos.z}, {name="default:water_source"})
|
||||
else
|
||||
abstract_dryplants.grow_reedmace({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
grow_reedmace({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
end
|
||||
end
|
||||
})
|
||||
@ -326,89 +320,121 @@ minetest.register_entity("dryplants:reedmace_water_entity",{
|
||||
end,
|
||||
})
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- SPAWN REEDMACE
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--[[biome_lib.register_active_spawner({
|
||||
spawn_delay = 1200,
|
||||
spawn_plants = {"dryplants:reedmace_sapling"},
|
||||
spawn_chance = 400,
|
||||
spawn_surfaces = {
|
||||
"default:dirt_with_grass",
|
||||
"default:desert_sand",
|
||||
"default:sand",
|
||||
"dryplants:grass_short",
|
||||
"stoneage:grass_with_silex"
|
||||
},
|
||||
seed_diff = 329,
|
||||
near_nodes = {"default:water_source"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
})]]
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- GENERATE REEDMACE
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- near water or swamp
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
minetest.register_decoration({
|
||||
name = "dryplants:reedmace_swamp",
|
||||
decoration = {"air"},
|
||||
fill_ratio = "0.1",
|
||||
y_min = 1,
|
||||
y_max = 40,
|
||||
place_on = {
|
||||
"default:dirt_with_grass",
|
||||
"default:desert_sand",
|
||||
"stoneage:grass_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
max_count = 35,
|
||||
rarity = 101 - 40,
|
||||
--rarity = 60,
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
abstract_dryplants.grow_reedmace
|
||||
)
|
||||
deco_type = "simple",
|
||||
flags = "all_floors",
|
||||
spawn_by = {
|
||||
"default:water_source",
|
||||
"sumpf:dirtywater_source",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
check_offset = -1,
|
||||
num_spawn_by = 1
|
||||
})
|
||||
|
||||
-- in water
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
minetest.register_decoration({
|
||||
name = "dryplants:reedmace_water",
|
||||
decoration = {"air"},
|
||||
fill_ratio = "0.01",
|
||||
y_min = 0,
|
||||
y_max = 0,
|
||||
place_on = {
|
||||
"default:dirt",
|
||||
"default:dirt_with_grass",
|
||||
--"default:desert_sand",
|
||||
--"stoneage:grass_with_silex",
|
||||
"stoneage:sand_with_silex",
|
||||
"sumpf:peat",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
max_count = 35,
|
||||
rarity = 101 - 65,
|
||||
--rarity = 35,
|
||||
min_elevation = 0, -- a bit below sea level
|
||||
max_elevation = 0, -- ""
|
||||
near_nodes = {"default:water_source","sumpf:dirtywater_source"},
|
||||
near_nodes_size = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
abstract_dryplants.grow_reedmace_water
|
||||
)
|
||||
deco_type = "simple",
|
||||
flags = "all_floors",
|
||||
spawn_by = {
|
||||
"default:water_source",
|
||||
"sumpf:dirtywater_source"
|
||||
},
|
||||
check_offset = -1,
|
||||
num_spawn_by = 1
|
||||
})
|
||||
|
||||
-- for oases & tropical beaches & tropical swamps
|
||||
biome_lib.register_on_generate({
|
||||
surface = {
|
||||
minetest.register_decoration({
|
||||
name = "dryplants:reedmace_beach",
|
||||
decoration = {"air"},
|
||||
fill_ratio = "0.1",
|
||||
y_min = 1,
|
||||
y_max = 40,
|
||||
place_on = {
|
||||
"default:sand",
|
||||
"sumpf:sumpf"
|
||||
},
|
||||
max_count = 35,
|
||||
rarity = 101 - 90,
|
||||
--rarity = 10,
|
||||
neighbors = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
|
||||
ncount = 1,
|
||||
min_elevation = 1, -- above sea level
|
||||
near_nodes = {"default:desert_sand","sumpf:sumpf"},
|
||||
near_nodes_size = 2,
|
||||
near_nodes_vertical = 1,
|
||||
near_nodes_count = 1,
|
||||
plantlife_limit = -0.9,
|
||||
},
|
||||
abstract_dryplants.grow_reedmace
|
||||
)
|
||||
deco_type = "simple",
|
||||
flags = "all_floors",
|
||||
spawn_by = {
|
||||
"default:water_source",
|
||||
"sumpf:dirtywater_source",
|
||||
"sumpf:sumpf",
|
||||
"default:desert_sand"
|
||||
},
|
||||
check_offset = -1,
|
||||
num_spawn_by = 1
|
||||
})
|
||||
|
||||
local did, did2, did3
|
||||
minetest.register_on_mods_loaded(function()
|
||||
did = minetest.get_decoration_id("dryplants:reedmace_swamp")
|
||||
did2 = minetest.get_decoration_id("dryplants:reedmace_water")
|
||||
did3 = minetest.get_decoration_id("dryplants:reedmace_beach")
|
||||
minetest.set_gen_notify("decoration", {did, did2, did3})
|
||||
end)
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local g = minetest.get_mapgen_object("gennotify")
|
||||
local locations = {}
|
||||
|
||||
local deco_locations_1 = g["decoration#" .. did] or {}
|
||||
local deco_locations_3 = g["decoration#" .. did3] or {}
|
||||
|
||||
for _, pos in pairs(deco_locations_1) do
|
||||
locations[#locations+1] = pos
|
||||
end
|
||||
for _, pos in pairs(deco_locations_3) do
|
||||
locations[#locations+1] = pos
|
||||
end
|
||||
|
||||
if #locations == 0 then return end
|
||||
for _, pos in ipairs(locations) do
|
||||
print(minetest.pos_to_string(pos))
|
||||
grow_reedmace(pos)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
local g = minetest.get_mapgen_object("gennotify")
|
||||
local locations = {}
|
||||
|
||||
local deco_locations_2 = g["decoration#" .. did2] or {}
|
||||
|
||||
for _, pos in pairs(deco_locations_2) do
|
||||
locations[#locations+1] = pos
|
||||
end
|
||||
|
||||
if #locations == 0 then return end
|
||||
for _, pos in ipairs(locations) do
|
||||
grow_reedmace_water(pos)
|
||||
end
|
||||
end)
|
||||
|
Reference in New Issue
Block a user