From 85b633d3f6cc521b0946898fe18b1c18d0d0d886 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Fri, 16 Aug 2024 18:30:17 +0100 Subject: [PATCH] added custom spawn check and examples --- mobs_crocs/init.lua | 95 +++++++++++++++++++------------- mobs_crocs/spawn_example.lua | 52 +++++++++++++++++ mobs_fish/init.lua | 71 +++++++++++++----------- mobs_fish/spawn_example.lua | 24 ++++++++ mobs_jellyfish/init.lua | 27 +++++---- mobs_jellyfish/spawn_example.lua | 12 ++++ mobs_sharks/SETTINGS.txt | 8 --- mobs_sharks/init.lua | 87 +++++++++++++++++------------ mobs_sharks/settingtypes.txt | 3 + mobs_sharks/spawn_example.lua | 44 +++++++++++++++ mobs_turtles/init.lua | 70 ++++++++++++----------- mobs_turtles/spawn_example.lua | 30 ++++++++++ 12 files changed, 368 insertions(+), 155 deletions(-) create mode 100644 mobs_crocs/spawn_example.lua create mode 100644 mobs_fish/spawn_example.lua create mode 100644 mobs_jellyfish/spawn_example.lua delete mode 100644 mobs_sharks/SETTINGS.txt create mode 100755 mobs_sharks/settingtypes.txt create mode 100644 mobs_sharks/spawn_example.lua create mode 100644 mobs_turtles/spawn_example.lua diff --git a/mobs_crocs/init.lua b/mobs_crocs/init.lua index 852ef6b..7f5dd20 100644 --- a/mobs_crocs/init.lua +++ b/mobs_crocs/init.lua @@ -67,21 +67,6 @@ if croc_walkers then mobs:register_mob("mobs_crocs:crocodile", table.copy(croc_def)) mobs:register_egg("mobs_crocs:crocodile", "Crocodile (walk)", "default_grass.png", 1) - - mobs:spawn({ - name = "mobs_crocs:crocodile", - nodes = { - (mod_mcl and "group:shovely" or "group:crumbly") - }, - neighbors = { - "group:water", "dryplants:juncus", "dryplants:reedmace", - (mod_mcl and "mcl_core:reeds" or "default:papyrus") - }, - interval = 30, - chance = croc_spawn_chance, - min_height = 0, - max_height = 10 - }) end @@ -95,20 +80,6 @@ if croc_floaters then mobs:register_mob("mobs_crocs:crocodile_float", table.copy(croc_def)) mobs:register_egg("mobs_crocs:crocodile_float", "Crocodile (float)", "default_grass.png", 1) - - mobs:spawn({ - name = "mobs_crocs:crocodile_float", - nodes = {"group:water"}, - neighbors = { - (mcl_core and "group:shovely" or "group:crumbly"), - "group:seaplants", "dryplants:juncus", "dryplants:reedmace", - (mod_mcl and "mcl_core:reeds" or "default:papyrus") - }, - interval = 30, - chance = croc_spawn_chance, - min_height = -3, - max_height = 10 - }) end @@ -125,17 +96,63 @@ if croc_swimmers then mobs:register_mob("mobs_crocs:crocodile_swim", table.copy(croc_def)) mobs:register_egg("mobs_crocs:crocodile_swim", "Crocodile (swim)", "default_grass.png", 1) - - mobs:spawn({ - name = "mobs_crocs:crocodile_swim", - nodes = {"group:water"}, - neighbors = {(mcl_core and "group:shovely" or "group:crumbly")}, - interval = 30, - chance = croc_spawn_chance, - min_height = -8, - max_height = 10 - }) end +-- Check for custom spawn.lua + +local MP = minetest.get_modpath(minetest.get_current_modname()) .. "/" +local input = io.open(MP .. "spawn.lua", "r") + +if input then + input:close() ; input = nil ; dofile(MP .. "spawn.lua") +else + if croc_walkers then + + mobs:spawn({ + name = "mobs_crocs:crocodile", + nodes = { + (mod_mcl and "group:shovely" or "group:crumbly") + }, + neighbors = { + "group:water", "dryplants:juncus", "dryplants:reedmace", + (mod_mcl and "mcl_core:reeds" or "default:papyrus") + }, + interval = 30, + chance = croc_spawn_chance, + min_height = 0, + max_height = 10 + }) + end + + if croc_floaters then + + mobs:spawn({ + name = "mobs_crocs:crocodile_float", + nodes = {"group:water"}, + neighbors = { + (mcl_core and "group:shovely" or "group:crumbly"), + "group:seaplants", "dryplants:juncus", "dryplants:reedmace", + (mod_mcl and "mcl_core:reeds" or "default:papyrus") + }, + interval = 30, + chance = croc_spawn_chance, + min_height = -3, + max_height = 10 + }) + end + + if croc_swimmers then + + mobs:spawn({ + name = "mobs_crocs:crocodile_swim", + nodes = {"group:water"}, + neighbors = {(mcl_core and "group:shovely" or "group:crumbly")}, + interval = 30, + chance = croc_spawn_chance, + min_height = -8, + max_height = 10 + }) + end +end print("[MOD] Mobs Redo Crocs loaded") diff --git a/mobs_crocs/spawn_example.lua b/mobs_crocs/spawn_example.lua new file mode 100644 index 0000000..09fe429 --- /dev/null +++ b/mobs_crocs/spawn_example.lua @@ -0,0 +1,52 @@ + +-- load settings + +local croc_walkers = minetest.settings:get_bool("mobs_crocs.enable_walkers", true) +local croc_floaters = minetest.settings:get_bool("mobs_crocs.enable_floaters", true) +local croc_swimmers = minetest.settings:get_bool("mobs_crocs.enable_swimmers", true) + +-- spawn examples + +if croc_walkers then + + mobs:spawn({ + name = "mobs_crocs:crocodile", + nodes = {"group:crumbly"}, + neighbors = { + "group:water", "dryplants:juncus", "dryplants:reedmace", "default:papyrus" + }, + interval = 30, + chance = 20000, + min_height = 0, + max_height = 10 + }) +end + +if croc_floaters then + + mobs:spawn({ + name = "mobs_crocs:crocodile_float", + nodes = {"group:water"}, + neighbors = { + "group:crumbly", "group:seaplants", "dryplants:juncus", + "dryplants:reedmace", "default:papyrus" + }, + interval = 30, + chance = 20000, + min_height = -3, + max_height = 10 + }) +end + +if croc_swimmers then + + mobs:spawn({ + name = "mobs_crocs:crocodile_swim", + nodes = {"group:water"}, + neighbors = {"group:crumbly"}, + interval = 30, + chance = 20000, + min_height = -8, + max_height = 10 + }) +end diff --git a/mobs_fish/init.lua b/mobs_fish/init.lua index 6b0fc76..ad1f276 100644 --- a/mobs_fish/init.lua +++ b/mobs_fish/init.lua @@ -84,22 +84,6 @@ mobs:register_mob("mobs_fish:clownfish", { end }) --- spawn in world - -mobs:spawn({ - name = "mobs_fish:clownfish", - nodes = {"group:water"}, - neighbors = { - (mod_mcl and "group:shovely" or "group:crumbly"), - "group:seaplants", "group:seacoral" - }, - min_light = 5, - interval = 30, - chance = l_spawn_chance, - max_height = l_water_level, - active_object_count = 5 -}) - -- spawn egg mobs:register_egg("mobs_fish:clownfish", "Clownfish", "animal_clownfish_clownfish_item.png", 0) @@ -156,27 +140,50 @@ mobs:register_mob("mobs_fish:tropical", { end }) --- spawn in world - -mobs:spawn({ - name = "mobs_fish:tropical", - nodes = {"group:water"}, - neighbors = { - (mod_mcl and "group:shovely" or "group:crumbly"), - "group:seaplants", "group:seacoral" - }, - min_light = 5, - interval = 30, - chance = l_spawn_chance, - max_height = l_water_level, - active_object_count = 5 -}) - -- spawn egg mobs:register_egg("mobs_fish:tropical", "Tropical fish", "animal_fish_blue_white_fish_blue_white_item.png", 0) +-- Check for custom spawn.lua + +local MP = minetest.get_modpath(minetest.get_current_modname()) .. "/" +local input = io.open(MP .. "spawn.lua", "r") + +if input then + input:close() ; input = nil ; dofile(MP .. "spawn.lua") +else + -- clownfish + mobs:spawn({ + name = "mobs_fish:clownfish", + nodes = {"group:water"}, + neighbors = { + (mod_mcl and "group:shovely" or "group:crumbly"), + "group:seaplants", "group:seacoral" + }, + min_light = 5, + interval = 30, + chance = l_spawn_chance, + max_height = l_water_level, + active_object_count = 5 + }) + + -- tropical fish + mobs:spawn({ + name = "mobs_fish:tropical", + nodes = {"group:water"}, + neighbors = { + (mod_mcl and "group:shovely" or "group:crumbly"), + "group:seaplants", "group:seacoral" + }, + min_light = 5, + interval = 30, + chance = l_spawn_chance, + max_height = l_water_level, + active_object_count = 5 + }) +end + -- helper function local function add_food_group(item) diff --git a/mobs_fish/spawn_example.lua b/mobs_fish/spawn_example.lua new file mode 100644 index 0000000..7f0ee8f --- /dev/null +++ b/mobs_fish/spawn_example.lua @@ -0,0 +1,24 @@ + +-- Fish spawn examples + +mobs:spawn({ + name = "mobs_fish:clownfish", + nodes = {"group:water"}, + neighbors = {"group:crumbly", "group:seaplants", "group:seacoral"}, + min_light = 5, + interval = 30, + chance = 10000, + max_height = -1, + active_object_count = 5 +}) + +mobs:spawn({ + name = "mobs_fish:tropical", + nodes = {"group:water"}, + neighbors = {"group:crumbly", "group:seaplants", "group:seacoral"}, + min_light = 5, + interval = 30, + chance = 10000, + max_height = -1, + active_object_count = 5 +}) diff --git a/mobs_jellyfish/init.lua b/mobs_jellyfish/init.lua index 311cb2a..6aa85f7 100644 --- a/mobs_jellyfish/init.lua +++ b/mobs_jellyfish/init.lua @@ -37,17 +37,24 @@ mobs:register_mob("mobs_jellyfish:jellyfish", { end }) --- spawn in world +-- Check for custom spawn.lua -mobs:spawn({ - name = "mobs_jellyfish:jellyfish", - nodes = {(mod_mcl and "mcl_core:water_source" or "default:water_source")}, - neighbors = {"group:water"}, - min_light = 5, - interval = 30, - chance = 10000, - max_height = 0 -}) +local MP = minetest.get_modpath(minetest.get_current_modname()) .. "/" +local input = io.open(MP .. "spawn.lua", "r") + +if input then + input:close() ; input = nil ; dofile(MP .. "spawn.lua") +else + mobs:spawn({ + name = "mobs_jellyfish:jellyfish", + nodes = {(mod_mcl and "mcl_core:water_source" or "default:water_source")}, + neighbors = {"group:water"}, + min_light = 5, + interval = 30, + chance = 10000, + max_height = 0 + }) +end -- spawn egg diff --git a/mobs_jellyfish/spawn_example.lua b/mobs_jellyfish/spawn_example.lua new file mode 100644 index 0000000..d58890a --- /dev/null +++ b/mobs_jellyfish/spawn_example.lua @@ -0,0 +1,12 @@ + +-- Jellyfish spawn example + +mobs:spawn({ + name = "mobs_jellyfish:jellyfish", + nodes = {"default:water_source"}, + neighbors = {"group:water"}, + min_light = 5, + interval = 30, + chance = 10000, + max_height = 0 +}) diff --git a/mobs_sharks/SETTINGS.txt b/mobs_sharks/SETTINGS.txt deleted file mode 100644 index bf27b35..0000000 --- a/mobs_sharks/SETTINGS.txt +++ /dev/null @@ -1,8 +0,0 @@ - --- SETTINGS - -ENABLE_SHARK_LARGE = true -ENABLE_SHARK_MEDIUM = true -ENABLE_SHARK_SMALL = true - -HELP_WITH_EXPERIMENT = false diff --git a/mobs_sharks/init.lua b/mobs_sharks/init.lua index b1df694..93fd77e 100644 --- a/mobs_sharks/init.lua +++ b/mobs_sharks/init.lua @@ -23,17 +23,19 @@ local l_spawn_chance = 60000 -- load settings -dofile(minetest.get_modpath("mobs_sharks") .. "/SETTINGS.txt") +local ENABLE_LARGE = minetest.settings:get_bool("mobs_sharks.enable_large") ~= false +local ENABLE_MEDIUM = minetest.settings:get_bool("mobs_sharks.enable_medium") ~= false +local ENABLE_SMALL = minetest.settings:get_bool("mobs_sharks.enable_small") ~= false -if not ENABLE_SHARK_LARGE then +if not ENABLE_LARGE then l_spawn_chance = l_spawn_chance - 20000 end -if not ENABLE_SHARK_MEDIUM then +if not ENABLE_MEDIUM then l_spawn_chance = l_spawn_chance - 20000 end -if not ENABLE_SHARK_SMALL then +if not ENABLE_SMALL then l_spawn_chance = l_spawn_chance - 20000 end @@ -43,7 +45,7 @@ local mod_mcl = minetest.get_modpath("mcl_core") -- large -if ENABLE_SHARK_LARGE then +if ENABLE_LARGE then mobs:register_mob("mobs_sharks:shark_lg", { type = "monster", @@ -83,22 +85,13 @@ if ENABLE_SHARK_LARGE then } }) - mobs:spawn({ - name = "mobs_sharks:shark_lg", - nodes = {"group:water"}, - neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, - interval = 30, - chance = l_spawn_chance, - max_height = 0 - }) - mobs:register_egg("mobs_sharks:shark_lg", "Shark (large)", "mob_shark_shark_item.png", 0) end -- medium -if ENABLE_SHARK_MEDIUM then +if ENABLE_MEDIUM then mobs:register_mob("mobs_sharks:shark_md", { type = "monster", @@ -138,22 +131,13 @@ if ENABLE_SHARK_MEDIUM then } }) - mobs:spawn({ - name = "mobs_sharks:shark_md", - nodes = {"group:water"}, - neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, - interval = 30, - chance = l_spawn_chance, - max_height = 0 - }) - mobs:register_egg("mobs_sharks:shark_md", "Shark (medium)", "mob_shark_shark_item.png", 0) end -- small -if ENABLE_SHARK_SMALL then +if ENABLE_SMALL then mobs:register_mob("mobs_sharks:shark_sm", { type = "monster", @@ -193,18 +177,53 @@ if ENABLE_SHARK_SMALL then } }) - mobs:spawn({ - name = "mobs_sharks:shark_sm", - nodes = {"group:water"}, - neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, - interval = 30, - chance = l_spawn_chance, - max_height = 0 - }) - mobs:register_egg("mobs_sharks:shark_sm", "Shark (small)", "mob_shark_shark_item.png", 0) end +-- Check for custom spawn.lua + +local MP = minetest.get_modpath(minetest.get_current_modname()) .. "/" +local input = io.open(MP .. "spawn.lua", "r") + +if input then + input:close() ; input = nil ; dofile(MP .. "spawn.lua") +else + if ENABLE_SMALL then + + mobs:spawn({ + name = "mobs_sharks:shark_sm", + nodes = {"group:water"}, + neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, + interval = 30, + chance = l_spawn_chance, + max_height = 0 + }) + end + + if ENABLE_MEDIUM then + + mobs:spawn({ + name = "mobs_sharks:shark_md", + nodes = {"group:water"}, + neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, + interval = 30, + chance = l_spawn_chance, + max_height = 0 + }) + end + + if ENABLE_LARGE then + + mobs:spawn({ + name = "mobs_sharks:shark_lg", + nodes = {"group:water"}, + neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, + interval = 30, + chance = l_spawn_chance, + max_height = 0 + }) + end +end print("[MOD] Mobs Redo Sharks loaded") diff --git a/mobs_sharks/settingtypes.txt b/mobs_sharks/settingtypes.txt new file mode 100755 index 0000000..6838054 --- /dev/null +++ b/mobs_sharks/settingtypes.txt @@ -0,0 +1,3 @@ +mobs_sharks.enable_large (Enable Large Sharks) bool true +mobs_sharks.enable_medium (Enable Medium Sharks) bool true +mobs_sharks.enable_small (Enable Small Sharks) bool true diff --git a/mobs_sharks/spawn_example.lua b/mobs_sharks/spawn_example.lua new file mode 100644 index 0000000..b76d35f --- /dev/null +++ b/mobs_sharks/spawn_example.lua @@ -0,0 +1,44 @@ + +-- load settings + +local ENABLE_LARGE = minetest.settings:get_bool("mobs_sharks.enable_large") ~= false +local ENABLE_MEDIUM = minetest.settings:get_bool("mobs_sharks.enable_medium") ~= false +local ENABLE_SMALL = minetest.settings:get_bool("mobs_sharks.enable_small") ~= false + +-- Shark spawn examples + +if ENABLE_SMALL then + + mobs:spawn({ + name = "mobs_sharks:shark_sm", + nodes = {"group:water"}, + neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, + interval = 30, + chance = 20000, + max_height = 0 + }) +end + +if ENABLE_MEDIUM then + + mobs:spawn({ + name = "mobs_sharks:shark_md", + nodes = {"group:water"}, + neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, + interval = 30, + chance = 20000, + max_height = 0 + }) +end + +if ENABLE_LARGE then + + mobs:spawn({ + name = "mobs_sharks:shark_lg", + nodes = {"group:water"}, + neighbors = {"group:water", "seawrecks:woodship", "seawrecks:uboot"}, + interval = 30, + chance = 20000, + max_height = 0 + }) +end diff --git a/mobs_turtles/init.lua b/mobs_turtles/init.lua index 060ec12..d9f3dbc 100644 --- a/mobs_turtles/init.lua +++ b/mobs_turtles/init.lua @@ -80,24 +80,6 @@ mobs:register_mob("mobs_turtles:turtle", { end }) --- spawn in world - -mobs:spawn({ - name = "mobs_turtles:turtle", - nodes = {(mod_mcl and "group:shovely" or "group:crumbly")}, - neighbors = { - (mod_mcl and "groups:shovely" or "group:crumbly"), - (mod_mcl and "mcl_core:reeds" or "default:papyrus"), - (mod_mcl and "mcl_core:cactus" or "default:cactus"), - "dryplants:juncus", "dryplants:reedmace" - }, - min_light = 5, - interval = 30, - chance = l_spawn_chance, - min_height = 1, - max_height = 10 -}) - -- spawn egg mobs:register_egg("mobs_turtles:turtle", "Turtle", "default_grass.png", 1) @@ -146,23 +128,47 @@ mobs:register_mob("mobs_turtles:seaturtle", { end }) --- spawn in world - -mobs:spawn({ - name = "mobs_turtles:seaturtle", - nodes = {"group:water"}, - neighbors = { - "group:water", "group:seaplants", "seawrecks:woodship", "seawrecks:uboot" - }, - min_light = 5, - interval = 30, - chance = l_spawn_chance, - max_height = 0 -}) - -- spawn egg mobs:register_egg("mobs_turtles:seaturtle", "Sea Turtle", "default_water.png", 1) +-- Check for custom spawn.lua + +local MP = minetest.get_modpath(minetest.get_current_modname()) .. "/" +local input = io.open(MP .. "spawn.lua", "r") + +if input then + input:close() ; input = nil ; dofile(MP .. "spawn.lua") +else + -- land turtle + mobs:spawn({ + name = "mobs_turtles:turtle", + nodes = {(mod_mcl and "group:shovely" or "group:crumbly")}, + neighbors = { + (mod_mcl and "groups:shovely" or "group:crumbly"), + (mod_mcl and "mcl_core:reeds" or "default:papyrus"), + (mod_mcl and "mcl_core:cactus" or "default:cactus"), + "dryplants:juncus", "dryplants:reedmace" + }, + min_light = 5, + interval = 30, + chance = l_spawn_chance, + min_height = 1, + max_height = 10 + }) + + -- sea turtle + mobs:spawn({ + name = "mobs_turtles:seaturtle", + nodes = {"group:water"}, + neighbors = { + "group:water", "group:seaplants", "seawrecks:woodship", "seawrecks:uboot" + }, + min_light = 5, + interval = 30, + chance = l_spawn_chance, + max_height = 0 + }) +end print("[MOD] Mobs Redo Turtles loaded") diff --git a/mobs_turtles/spawn_example.lua b/mobs_turtles/spawn_example.lua new file mode 100644 index 0000000..eefe4fd --- /dev/null +++ b/mobs_turtles/spawn_example.lua @@ -0,0 +1,30 @@ + +-- Turtle spawn examples + +-- land turtle +mobs:spawn({ + name = "mobs_turtles:turtle", + nodes = {"group:crumbly"}, + neighbors = { + "group:crumbly", "default:papyrus", "default:cactus", + "dryplants:juncus", "dryplants:reedmace" + }, + min_light = 5, + interval = 30, + chance = 30000, + min_height = 1, + max_height = 10 +}) + +-- sea turtle +mobs:spawn({ + name = "mobs_turtles:seaturtle", + nodes = {"group:water"}, + neighbors = { + "group:water", "group:seaplants", "seawrecks:woodship", "seawrecks:uboot" + }, + min_light = 5, + interval = 30, + chance = 30000, + max_height = 0 +})