From b069341d33ef91a957b2493999647545a98f76c5 Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Wed, 20 Aug 2014 18:35:08 +1000 Subject: [PATCH] Stop polluting global namespace --- ferns/fern.lua | 221 ++++++++++++++++++++-------------------- ferns/gianttreefern.lua | 99 +++++++++--------- ferns/horsetail.lua | 149 ++++++++++++++------------- ferns/init.lua | 10 +- ferns/settings.lua | 31 +++--- ferns/treefern.lua | 97 +++++++++--------- 6 files changed, 310 insertions(+), 297 deletions(-) diff --git a/ferns/fern.lua b/ferns/fern.lua index ef7e5b2..38071a8 100644 --- a/ferns/fern.lua +++ b/ferns/fern.lua @@ -127,123 +127,126 @@ plantslib:spawn_on_surfaces({ }, seed_diff = 329, })]] -if Ferns_near_Tree == true then -plantslib:register_generate_plant({ -- near trees (woodlands) - surface = { - "default:dirt_with_grass", - "default:mossycobble", - "default:desert_sand", - "default:sand", - "default:jungletree", - "stoneage:grass_with_silex", - "sumpf:sumpf" + +assert(abstract_ferns.config.Lady_fern == true) + +if abstract_ferns.config.Ferns_near_Tree == true then + plantslib:register_generate_plant({ -- near trees (woodlands) + surface = { + "default:dirt_with_grass", + "default:mossycobble", + "default:desert_sand", + "default:sand", + "default:jungletree", + "stoneage:grass_with_silex", + "sumpf:sumpf" + }, + max_count = 30, + rarity = 62,--63, + min_elevation = 1, -- above sea level + near_nodes = {"group:tree"}, + near_nodes_size = 3,--4, + near_nodes_vertical = 2,--3, + near_nodes_count = 1, + plantlife_limit = -0.9, + humidity_max = -1.0, + humidity_min = 0.4, + temp_max = -0.5, -- 55 °C (too hot?) + temp_min = 0.75, -- -12 °C }, - max_count = 30, - rarity = 62,--63, - min_elevation = 1, -- above sea level - near_nodes = {"group:tree"}, - near_nodes_size = 3,--4, - near_nodes_vertical = 2,--3, - near_nodes_count = 1, - plantlife_limit = -0.9, - humidity_max = -1.0, - humidity_min = 0.4, - temp_max = -0.5, -- 55 °C (too hot?) - temp_min = 0.75, -- -12 °C - }, - abstract_ferns.grow_fern -) + abstract_ferns.grow_fern + ) end -if Ferns_near_Rock == true then -plantslib:register_generate_plant({ -- near stone (mountains) - surface = { - "default:dirt_with_grass", - "default:mossycobble", - "group:falling_node", - --"default:jungletree", - "stoneage:grass_with_silex", - "sumpf:sumpf" +if abstract_ferns.config.Ferns_near_Rock == true then + plantslib:register_generate_plant({ -- near stone (mountains) + surface = { + "default:dirt_with_grass", + "default:mossycobble", + "group:falling_node", + --"default:jungletree", + "stoneage:grass_with_silex", + "sumpf:sumpf" + }, + max_count = 35, + rarity = 40, + min_elevation = 1, -- above sea level + near_nodes = {"group:stone"}, + near_nodes_size = 1, + near_nodes_count = 16, + plantlife_limit = -0.9, + humidity_max = -1.0, + humidity_min = 0.4, + temp_max = -0.5, -- 55 °C (too hot?) + temp_min = 0.75, -- -12 °C }, - max_count = 35, - rarity = 40, - min_elevation = 1, -- above sea level - near_nodes = {"group:stone"}, - near_nodes_size = 1, - near_nodes_count = 16, - plantlife_limit = -0.9, - humidity_max = -1.0, - humidity_min = 0.4, - temp_max = -0.5, -- 55 °C (too hot?) - temp_min = 0.75, -- -12 °C - }, - abstract_ferns.grow_fern -) + abstract_ferns.grow_fern + ) end -if Ferns_near_Ores == true then -- this one causes a huge fps drop -plantslib:register_generate_plant({ -- near ores (potential mining sites) - surface = { - "default:dirt_with_grass", - "default:mossycobble", - "default:stone_with_coal", - "default:stone_with_iron", - "moreores:mineral_tin", - "moreores:mineral_silver", - "sumpf:sumpf" +if abstract_ferns.config.Ferns_near_Ores == true then -- this one causes a huge fps drop + plantslib:register_generate_plant({ -- near ores (potential mining sites) + surface = { + "default:dirt_with_grass", + "default:mossycobble", + "default:stone_with_coal", + "default:stone_with_iron", + "moreores:mineral_tin", + "moreores:mineral_silver", + "sumpf:sumpf" + }, + max_count = 1200,--1600, -- maybe too much? :D + rarity = 25,--15, + min_elevation = 1, -- above sea level + near_nodes = { + "default:stone_with_iron", + --"default:stone_with_copper", + --"default:stone_with_mese", + --"default:stone_with_gold", + --"default:stone_with_diamond", + "moreores:mineral_tin", + "moreores:mineral_silver" + --"moreores:mineral_mithril" + }, + near_nodes_size = 2, + near_nodes_vertical = 4,--5,--6, + near_nodes_count = 2,--3, + plantlife_limit = -0.9, + humidity_max = -1.0, + humidity_min = 0.4, + temp_max = -0.5, -- 55 °C (too hot?) + temp_min = 0.75, -- -12 °C }, - max_count = 1200,--1600, -- maybe too much? :D - rarity = 25,--15, - min_elevation = 1, -- above sea level - near_nodes = { - "default:stone_with_iron", - --"default:stone_with_copper", - --"default:stone_with_mese", - --"default:stone_with_gold", - --"default:stone_with_diamond", - "moreores:mineral_tin", - "moreores:mineral_silver" - --"moreores:mineral_mithril" - }, - near_nodes_size = 2, - near_nodes_vertical = 4,--5,--6, - near_nodes_count = 2,--3, - plantlife_limit = -0.9, - humidity_max = -1.0, - humidity_min = 0.4, - temp_max = -0.5, -- 55 °C (too hot?) - temp_min = 0.75, -- -12 °C - }, - abstract_ferns.grow_fern -) + abstract_ferns.grow_fern + ) end -if Ferns_in_Groups == true then -- this one is meant as a replacement of Ferns_near_Ores -plantslib:register_generate_plant({ - surface = { - "default:dirt_with_grass", - "default:mossycobble", - "default:stone_with_coal", - "default:stone_with_iron", - "moreores:mineral_tin", - "moreores:mineral_silver", - "sumpf:sumpf" +if abstract_ferns.config.Ferns_in_Groups == true then -- this one is meant as a replacement of Ferns_near_Ores + plantslib:register_generate_plant({ + surface = { + "default:dirt_with_grass", + "default:mossycobble", + "default:stone_with_coal", + "default:stone_with_iron", + "moreores:mineral_tin", + "moreores:mineral_silver", + "sumpf:sumpf" + }, + max_count = 70, + rarity = 25,--15, + min_elevation = 1, -- above sea level + near_nodes = { + "default:stone" + }, + near_nodes_size = 2, + near_nodes_vertical = 2,--6, + near_nodes_count = 3, + plantlife_limit = -0.9, + humidity_max = -1.0, + humidity_min = 0.4, + temp_max = -0.5, -- 55 °C (too hot?) + temp_min = 0.75, -- -12 °C }, - max_count = 70, - rarity = 25,--15, - min_elevation = 1, -- above sea level - near_nodes = { - "default:stone" - }, - near_nodes_size = 2, - near_nodes_vertical = 2,--6, - near_nodes_count = 3, - plantlife_limit = -0.9, - humidity_max = -1.0, - humidity_min = 0.4, - temp_max = -0.5, -- 55 °C (too hot?) - temp_min = 0.75, -- -12 °C - }, - abstract_ferns.grow_fern -) + abstract_ferns.grow_fern + ) end diff --git a/ferns/gianttreefern.lua b/ferns/gianttreefern.lua index 624523e..d559962 100644 --- a/ferns/gianttreefern.lua +++ b/ferns/gianttreefern.lua @@ -276,58 +276,61 @@ minetest.register_abm({ ----------------------------------------------------------------------------------------------- -- GENERATE GIANT TREE FERN ----------------------------------------------------------------------------------------------- + +assert(abstract_ferns.config.Giant_Tree_Fern == true) + -- in jungles -if Giant_Tree_Ferns_in_Jungle == true then -plantslib:register_generate_plant({ - surface = { - "default:dirt_with_grass", - "default:sand", - "default:desert_sand"--, - --"dryplants:grass_short" +if abstract_ferns.config.Giant_Tree_Ferns_in_Jungle == true then + plantslib:register_generate_plant({ + surface = { + "default:dirt_with_grass", + "default:sand", + "default:desert_sand"--, + --"dryplants:grass_short" + }, + max_count = 12,--27, + avoid_nodes = {"group:tree"}, + avoid_radius = 3,--4, + rarity = 85, + seed_diff = 329, + min_elevation = 1, + near_nodes = {"default:jungletree"}, + near_nodes_size = 6, + near_nodes_vertical = 2,--4, + near_nodes_count = 1, + plantlife_limit = -0.9, + --humidity_max = 0.39,--1.0, + --humidity_min = 0.5, + --temp_max = -1,-- -1.2,-- -0.5, -- ~ 55C + --temp_min = -0.35,-- -0.07, -- ~ 25C }, - max_count = 12,--27, - avoid_nodes = {"group:tree"}, - avoid_radius = 3,--4, - rarity = 85, - seed_diff = 329, - min_elevation = 1, - near_nodes = {"default:jungletree"}, - near_nodes_size = 6, - near_nodes_vertical = 2,--4, - near_nodes_count = 1, - plantlife_limit = -0.9, - --humidity_max = 0.39,--1.0, - --humidity_min = 0.5, - --temp_max = -1,-- -1.2,-- -0.5, -- ~ 55C - --temp_min = -0.35,-- -0.07, -- ~ 25C - }, - abstract_ferns.grow_giant_tree_fern -) + abstract_ferns.grow_giant_tree_fern + ) end -- for oases & tropical beaches -if Giant_Tree_Ferns_for_Oases == true then -plantslib:register_generate_plant({ - surface = { - "default:sand"--, - --"default:desert_sand" +if abstract_ferns.config.Giant_Tree_Ferns_for_Oases == true then + plantslib:register_generate_plant({ + surface = { + "default:sand"--, + --"default:desert_sand" + }, + max_count = 10,--27, + rarity = 90, + seed_diff = 329, + neighbors = {"default:desert_sand"}, + ncount = 1, + min_elevation = 1, + near_nodes = {"default:water_source"}, + near_nodes_size = 2, + near_nodes_vertical = 1, + near_nodes_count = 1, + plantlife_limit = -0.9, + humidity_max = -1.0, + humidity_min = 1.0, + temp_max = -1.0, + temp_min = 1.0, }, - max_count = 10,--27, - rarity = 90, - seed_diff = 329, - neighbors = {"default:desert_sand"}, - ncount = 1, - min_elevation = 1, - near_nodes = {"default:water_source"}, - near_nodes_size = 2, - near_nodes_vertical = 1, - near_nodes_count = 1, - plantlife_limit = -0.9, - humidity_max = -1.0, - humidity_min = 1.0, - temp_max = -1.0, - temp_min = 1.0, - }, - abstract_ferns.grow_giant_tree_fern -) + abstract_ferns.grow_giant_tree_fern + ) end diff --git a/ferns/horsetail.lua b/ferns/horsetail.lua index bfab07e..7b480b0 100644 --- a/ferns/horsetail.lua +++ b/ferns/horsetail.lua @@ -94,85 +94,88 @@ minetest.register_node("ferns:horsetail_04", { -- the one in inventory ----------------------------------------------------------------------------------------------- -- Spawning ----------------------------------------------------------------------------------------------- -if Horsetails_Spawning == true then -plantslib:spawn_on_surfaces({ - spawn_delay = 1200, - spawn_plants = { - "ferns:horsetail_01", - "ferns:horsetail_02", - "ferns:horsetail_03", - "ferns:horsetail_04" - }, - spawn_chance = 400, - spawn_surfaces = { - "default:dirt_with_grass", - "default:desert_sand", - "default:sand", - "dryplants:grass_short", - "stoneage:grass_with_silex", - "default:mossycobble", - "default:gravel" - }, - seed_diff = 329, - min_elevation = 1, -- above sea level - near_nodes = {"default:water_source","default:gravel"}, - near_nodes_size = 2, - near_nodes_vertical = 1, - near_nodes_count = 1, -}) +if abstract_ferns.config.Horsetails_Spawning == true then + plantslib:spawn_on_surfaces({ + spawn_delay = 1200, + spawn_plants = { + "ferns:horsetail_01", + "ferns:horsetail_02", + "ferns:horsetail_03", + "ferns:horsetail_04" + }, + spawn_chance = 400, + spawn_surfaces = { + "default:dirt_with_grass", + "default:desert_sand", + "default:sand", + "dryplants:grass_short", + "stoneage:grass_with_silex", + "default:mossycobble", + "default:gravel" + }, + seed_diff = 329, + min_elevation = 1, -- above sea level + near_nodes = {"default:water_source","default:gravel"}, + near_nodes_size = 2, + near_nodes_vertical = 1, + near_nodes_count = 1, + }) end ----------------------------------------------------------------------------------------------- -- Generating ----------------------------------------------------------------------------------------------- -if Horsetails_on_Grass == true then -plantslib:register_generate_plant({ - surface = { - "default:dirt_with_grass", - "sumpf:sumpf" + +assert(abstract_ferns.config.Horsetails == true) + +if abstract_ferns.config.Horsetails_on_Grass == true then + plantslib:register_generate_plant({ + surface = { + "default:dirt_with_grass", + "sumpf:sumpf" + }, + max_count = 35, + rarity = 40, + min_elevation = 1, -- above sea level + near_nodes = { + "group:water", -- likes water (of course) + "default:gravel", -- near those on gravel + "default:sand", -- some like sand + "default:clay", -- some like clay + "stoneage:grass_with_silex", + "default:mossycobble", + "default:cobble", + "sumpf:sumpf" + }, + near_nodes_size = 3, + near_nodes_vertical = 2,--3, + near_nodes_count = 1, + plantlife_limit = -0.9, + humidity_min = 0.4, + temp_max = -0.5, -- 55 °C + temp_min = 0.53, -- 0 °C, dies back in winter }, - max_count = 35, - rarity = 40, - min_elevation = 1, -- above sea level - near_nodes = { - "group:water", -- likes water (of course) - "default:gravel", -- near those on gravel - "default:sand", -- some like sand - "default:clay", -- some like clay - "stoneage:grass_with_silex", - "default:mossycobble", - "default:cobble", - "sumpf:sumpf" - }, - near_nodes_size = 3, - near_nodes_vertical = 2,--3, - near_nodes_count = 1, - plantlife_limit = -0.9, - humidity_min = 0.4, - temp_max = -0.5, -- 55 °C - temp_min = 0.53, -- 0 °C, dies back in winter - }, - abstract_ferns.grow_horsetail -) + abstract_ferns.grow_horsetail + ) end -if Horsetails_on_Stony == true then -plantslib:register_generate_plant({ - surface = { - "default:gravel", -- roots go deep - "default:mossycobble", - "stoneage:dirt_with_silex", - "stoneage:grass_with_silex", - "stoneage:sand_with_silex"--, -- roots go deep - --"sumpf:sumpf" +if abstract_ferns.config.Horsetails_on_Stony == true then + plantslib:register_generate_plant({ + surface = { + "default:gravel", -- roots go deep + "default:mossycobble", + "stoneage:dirt_with_silex", + "stoneage:grass_with_silex", + "stoneage:sand_with_silex"--, -- roots go deep + --"sumpf:sumpf" + }, + max_count = 35, + rarity = 20, + min_elevation = 1, -- above sea level + plantlife_limit = -0.9, + humidity_min = 0.4, + temp_max = -0.5, -- 55 °C + temp_min = 0.53, -- 0 °C, dies back in winter }, - max_count = 35, - rarity = 20, - min_elevation = 1, -- above sea level - plantlife_limit = -0.9, - humidity_min = 0.4, - temp_max = -0.5, -- 55 °C - temp_min = 0.53, -- 0 °C, dies back in winter - }, - abstract_ferns.grow_horsetail -) + abstract_ferns.grow_horsetail + ) end diff --git a/ferns/init.lua b/ferns/init.lua index 7fad107..9ff293d 100644 --- a/ferns/init.lua +++ b/ferns/init.lua @@ -10,19 +10,19 @@ abstract_ferns = {} dofile(minetest.get_modpath("ferns").."/settings.lua") -if Lady_fern == true then -dofile(minetest.get_modpath("ferns").."/fern.lua") +if abstract_ferns.config.Lady_fern == true then + dofile(minetest.get_modpath("ferns").."/fern.lua") end -if Horsetails == true then +if abstract_ferns.Horsetails == true then dofile(minetest.get_modpath("ferns").."/horsetail.lua") end -if Tree_Fern == true then +if abstract_ferns.config.Tree_Fern == true then dofile(minetest.get_modpath("ferns").."/treefern.lua") end -if Giant_Tree_Fern == true then +if abstract_ferns.config.Giant_Tree_Fern == true then dofile(minetest.get_modpath("ferns").."/gianttreefern.lua") end diff --git a/ferns/settings.lua b/ferns/settings.lua index e34d2ba..ce9cbc7 100644 --- a/ferns/settings.lua +++ b/ferns/settings.lua @@ -13,30 +13,31 @@ -- If something is still unclear, don't hesitate to post your question @ https://forum.minetest.net/viewtopic.php?id=6921 +abstract_ferns.config = {} -- Which plants should generate/spawn? -Lady_fern = true -Horsetails = true -Tree_Fern = true -Giant_Tree_Fern = true +abstract_ferns.config.Lady_fern = true +abstract_ferns.config.Horsetails = true +abstract_ferns.config.Tree_Fern = true +abstract_ferns.config.Giant_Tree_Fern = true -- Where should they generate/spawn? (if they generate/spawn) -- -- Lady-Fern -Ferns_near_Tree = true -Ferns_near_Rock = true -Ferns_near_Ores = true -- if there's a bunch of ferns there's ores nearby, this one causes a huge fps drop -Ferns_in_Groups = false -- this one is meant as a replacement of Ferns_near_Ores: ferns tend to generate in groups, less fps drop, no hint for nearby ores +abstract_ferns.config.Ferns_near_Tree = true +abstract_ferns.config.Ferns_near_Rock = true +abstract_ferns.config.Ferns_near_Ores = true -- if there's a bunch of ferns there's ores nearby, this one causes a huge fps drop +abstract_ferns.config.Ferns_in_Groups = false -- this one is meant as a replacement of Ferns_near_Ores: ferns tend to generate in groups, less fps drop, no hint for nearby ores -- -- Horsetails -Horsetails_Spawning = false -- horsetails will grow in already explored areas, over time, near water or gravel -Horsetails_on_Grass = true -- on dirt with grass and swamp (sumpf mod) -Horsetails_on_Stony = true -- on gravel, mossy cobble and silex (stoneage mod) +abstract_ferns.config.Horsetails_Spawning = false -- horsetails will grow in already explored areas, over time, near water or gravel +abstract_ferns.config.Horsetails_on_Grass = true -- on dirt with grass and swamp (sumpf mod) +abstract_ferns.config.Horsetails_on_Stony = true -- on gravel, mossy cobble and silex (stoneage mod) -- -- Tree_Fern -Tree_Ferns_in_Jungle = true -Tree_Ferns_for_Oases = true -- for oases and tropical beaches +abstract_ferns.config.Tree_Ferns_in_Jungle = true +abstract_ferns.config.Tree_Ferns_for_Oases = true -- for oases and tropical beaches -- -- Giant_Tree_Fern -Giant_Tree_Ferns_in_Jungle = true -Giant_Tree_Ferns_for_Oases = true -- for oases and tropical beaches +abstract_ferns.config.Giant_Tree_Ferns_in_Jungle = true +abstract_ferns.config.Giant_Tree_Ferns_for_Oases = true -- for oases and tropical beaches diff --git a/ferns/treefern.lua b/ferns/treefern.lua index a507620..ce034dc 100644 --- a/ferns/treefern.lua +++ b/ferns/treefern.lua @@ -188,58 +188,61 @@ minetest.register_abm({ ----------------------------------------------------------------------------------------------- -- GENERATE TREE FERN ----------------------------------------------------------------------------------------------- + +assert(abstract_ferns.config.Tree_Fern == true) + -- in jungles -if Tree_Ferns_in_Jungle == true then -plantslib:register_generate_plant({ - surface = { - "default:dirt_with_grass", - "default:sand", - "default:desert_sand"--, - --"dryplants:grass_short" +if abstract_ferns.config.Tree_Ferns_in_Jungle == true then + plantslib:register_generate_plant({ + surface = { + "default:dirt_with_grass", + "default:sand", + "default:desert_sand"--, + --"dryplants:grass_short" + }, + max_count = 35,--27, + avoid_nodes = {"default:tree"}, + avoid_radius = 4, + rarity = 50, + seed_diff = 329, + min_elevation = -10, + near_nodes = {"default:jungletree"}, + near_nodes_size = 6, + near_nodes_vertical = 2,--4, + near_nodes_count = 1, + plantlife_limit = -0.9, + humidity_max = -1.0, + humidity_min = 0.4, + temp_max = -0.5, + temp_min = 0.13, }, - max_count = 35,--27, - avoid_nodes = {"default:tree"}, - avoid_radius = 4, - rarity = 50, - seed_diff = 329, - min_elevation = -10, - near_nodes = {"default:jungletree"}, - near_nodes_size = 6, - near_nodes_vertical = 2,--4, - near_nodes_count = 1, - plantlife_limit = -0.9, - humidity_max = -1.0, - humidity_min = 0.4, - temp_max = -0.5, - temp_min = 0.13, - }, - abstract_ferns.grow_tree_fern -) + abstract_ferns.grow_tree_fern + ) end -- for oases & tropical beaches -if Tree_Ferns_for_Oases == true then -plantslib:register_generate_plant({ - surface = { - "default:sand"--, - --"default:desert_sand" +if abstract_ferns.config.Tree_Ferns_for_Oases == true then + plantslib:register_generate_plant({ + surface = { + "default:sand"--, + --"default:desert_sand" + }, + max_count = 35, + rarity = 50, + seed_diff = 329, + neighbors = {"default:desert_sand"}, + ncount = 1, + min_elevation = 1, + near_nodes = {"default:water_source"}, + near_nodes_size = 2, + near_nodes_vertical = 1, + near_nodes_count = 1, + plantlife_limit = -0.9, + humidity_max = -1.0, + humidity_min = 1.0, + temp_max = -1.0, + temp_min = 1.0, }, - max_count = 35, - rarity = 50, - seed_diff = 329, - neighbors = {"default:desert_sand"}, - ncount = 1, - min_elevation = 1, - near_nodes = {"default:water_source"}, - near_nodes_size = 2, - near_nodes_vertical = 1, - near_nodes_count = 1, - plantlife_limit = -0.9, - humidity_max = -1.0, - humidity_min = 1.0, - temp_max = -1.0, - temp_min = 1.0, - }, - abstract_ferns.grow_tree_fern + abstract_ferns.grow_tree_fern ) end