From 4018a5c8e83b26ff8a54d8ecf779e28011a384a7 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Mon, 21 Sep 2020 10:03:08 +0100 Subject: [PATCH] Added spawn.lua check for custom mob spawns, example file included --- dirt_monster.lua | 2 + dungeon_master.lua | 2 + init.lua | 45 ++++++++---- lava_flan.lua | 2 + mese_monster.lua | 2 + oerkki.lua | 2 + sand_monster.lua | 3 +- spawn_example.lua | 173 +++++++++++++++++++++++++++++++++++++++++++++ spider.lua | 2 + stone_monster.lua | 2 + tree_monster.lua | 2 + 11 files changed, 224 insertions(+), 13 deletions(-) create mode 100644 spawn_example.lua diff --git a/dirt_monster.lua b/dirt_monster.lua index 3bf5fbd..518116a 100644 --- a/dirt_monster.lua +++ b/dirt_monster.lua @@ -57,6 +57,7 @@ if minetest.get_modpath("ethereal") then spawn_on = "ethereal:gray_dirt" end +if not mobs.custom_spawn_monster then mobs:spawn({ name = "mobs_monster:dirt_monster", nodes = {spawn_on}, @@ -67,6 +68,7 @@ mobs:spawn({ min_height = 0, day_toggle = false, }) +end mobs:register_egg("mobs_monster:dirt_monster", S("Dirt Monster"), "default_dirt.png", 1) diff --git a/dungeon_master.lua b/dungeon_master.lua index 044f106..bcc04f8 100644 --- a/dungeon_master.lua +++ b/dungeon_master.lua @@ -62,6 +62,7 @@ mobs:register_mob("mobs_monster:dungeon_master", { }) +if not mobs.custom_spawn_monster then mobs:spawn({ name = "mobs_monster:dungeon_master", nodes = {"default:stone"}, @@ -70,6 +71,7 @@ mobs:spawn({ active_object_count = 1, max_height = -70, }) +end mobs:register_egg("mobs_monster:dungeon_master", S("Dungeon Master"), "fire_basic_flame.png", 1, true) diff --git a/init.lua b/init.lua index 9f8b5f6..02142fd 100644 --- a/init.lua +++ b/init.lua @@ -1,22 +1,43 @@ -- Load support for intllib. -local path = minetest.get_modpath(minetest.get_current_modname()) +local path = minetest.get_modpath(minetest.get_current_modname()) .. "/" + local S = minetest.get_translator and minetest.get_translator("mobs_monster") or - dofile(path .. "/intllib.lua") + dofile(path .. "intllib.lua") + mobs.intllib = S + +-- Check for custom mob spawn file +local input = io.open(path .. "spawn.lua", "r") + +if input then + mobs.custom_spawn_monster = true + input:close() + input = nil +end + + -- Monsters -dofile(path .. "/dirt_monster.lua") -- PilzAdam -dofile(path .. "/dungeon_master.lua") -dofile(path .. "/oerkki.lua") -dofile(path .. "/sand_monster.lua") -dofile(path .. "/stone_monster.lua") -dofile(path .. "/tree_monster.lua") -dofile(path .. "/lava_flan.lua") -- Zeg9 -dofile(path .. "/mese_monster.lua") -dofile(path .. "/spider.lua") -- AspireMint +dofile(path .. "dirt_monster.lua") -- PilzAdam +dofile(path .. "dungeon_master.lua") +dofile(path .. "oerkki.lua") +dofile(path .. "sand_monster.lua") +dofile(path .. "stone_monster.lua") +dofile(path .. "tree_monster.lua") +dofile(path .. "lava_flan.lua") -- Zeg9 +dofile(path .. "mese_monster.lua") +dofile(path .. "spider.lua") -- AspireMint + + +-- Load custom spawning +if mobs.custom_spawn_monster then + dofile(path .. "spawn.lua") +end + -- Lucky Blocks -dofile(path .. "/lucky_block.lua") +dofile(path .. "lucky_block.lua") + print (S("[MOD] Mobs Redo Monsters loaded")) diff --git a/lava_flan.lua b/lava_flan.lua index 55de98f..f63a90c 100644 --- a/lava_flan.lua +++ b/lava_flan.lua @@ -89,6 +89,7 @@ mobs:register_mob("mobs_monster:lava_flan", { }) +if not mobs.custom_spawn_monster then mobs:spawn({ name = "mobs_monster:lava_flan", nodes = {"default:lava_source"}, @@ -96,6 +97,7 @@ mobs:spawn({ active_object_count = 1, max_height = 0, }) +end mobs:register_egg("mobs_monster:lava_flan", S("Lava Flan"), "default_lava.png", 1) diff --git a/mese_monster.lua b/mese_monster.lua index 40a99b2..a480a61 100644 --- a/mese_monster.lua +++ b/mese_monster.lua @@ -56,6 +56,7 @@ mobs:register_mob("mobs_monster:mese_monster", { }) +if not mobs.custom_spawn_monster then mobs:spawn({ name = "mobs_monster:mese_monster", nodes = {"default:stone"}, @@ -64,6 +65,7 @@ mobs:spawn({ active_object_count = 1, max_height = -20, }) +end mobs:register_egg("mobs_monster:mese_monster", S("Mese Monster"), "default_mese_block.png", 1) diff --git a/oerkki.lua b/oerkki.lua index 7cb40fe..6e42c42 100644 --- a/oerkki.lua +++ b/oerkki.lua @@ -60,6 +60,7 @@ mobs:register_mob("mobs_monster:oerkki", { }) +if not mobs.custom_spawn_monster then mobs:spawn({ name = "mobs_monster:oerkki", nodes = {"default:stone"}, @@ -67,6 +68,7 @@ mobs:spawn({ chance = 7000, max_height = -10, }) +end mobs:register_egg("mobs_monster:oerkki", S("Oerkki"), "default_obsidian.png", 1) diff --git a/sand_monster.lua b/sand_monster.lua index f1c67d5..a46f509 100644 --- a/sand_monster.lua +++ b/sand_monster.lua @@ -116,7 +116,7 @@ mobs:register_mob("mobs_monster:sand_monster", { ]] }) - +if not mobs.custom_spawn_monster then mobs:spawn({ name = "mobs_monster:sand_monster", nodes = {"default:desert_sand"}, @@ -124,6 +124,7 @@ mobs:spawn({ active_object_count = 2, min_height = 0, }) +end mobs:register_egg("mobs_monster:sand_monster", S("Sand Monster"), "default_desert_sand.png", 1) diff --git a/spawn_example.lua b/spawn_example.lua new file mode 100644 index 0000000..7babd08 --- /dev/null +++ b/spawn_example.lua @@ -0,0 +1,173 @@ + +--[[ Spawn Template, defaults to values shown if line not provided + +mobs:spawn({ + + name = "", + + - Name of mob, must be provided e.g. "mymod:my_mob" + + nodes = {"group:soil, "group:stone"}, + + - Nodes to spawn on top of. + + neighbors = {"air"}, + + - Nodes to spawn beside. + + min_light = 0, + + - Minimum light level. + + max_light = 15, + + - Maximum light level, 15 is sunlight only. + + interval = 30, + + - Spawn interval in seconds. + + chance = 5000, + + - Spawn chance, 1 in every 5000 nodes. + + active_object_count = 1, + + - Active mobs of this type in area. + + min_height = -31000, + + - Minimum height level. + + max_height = 31000, + + - Maximum height level. + + day_toggle = nil, + + - Daytime toggle, true to spawn during day, false for night, nil for both + + on_spawn = nil, + + - On spawn function to run when mob spawns in world + + on_map_load = nil, + + - On map load, when true mob only spawns in newly generated map areas +}) +]]-- + + +-- Dirt Monster + +mobs:spawn({ + name = "mobs_monster:dirt_monster", + nodes = {"default:dirt_with_grass"}, + min_light = 0, + max_light = 7, + chance = 6000, + active_object_count = 2, + min_height = 0, + day_toggle = false, +}) + +-- Dungeon Master + +mobs:spawn({ + name = "mobs_monster:dungeon_master", + nodes = {"default:stone"}, + max_light = 5, + chance = 9000, + active_object_count = 1, + max_height = -70, +}) + +-- Lava Flan + +mobs:spawn({ + name = "mobs_monster:lava_flan", + nodes = {"default:lava_source"}, + chance = 1500, + active_object_count = 1, + max_height = 0, +}) + +-- Mese Monster + +mobs:spawn({ + name = "mobs_monster:mese_monster", + nodes = {"default:stone"}, + max_light = 7, + chance = 5000, + active_object_count = 1, + max_height = -20, +}) + +-- Oerkki + +mobs:spawn({ + name = "mobs_monster:oerkki", + nodes = {"default:stone"}, + max_light = 7, + chance = 7000, + max_height = -10, +}) + +-- Sand Monster + +mobs:spawn({ + name = "mobs_monster:sand_monster", + nodes = {"default:desert_sand"}, + chance = 7000, + active_object_count = 2, + min_height = 0, +}) + +-- Spider (above ground) + +mobs:spawn({ + name = "mobs_monster:spider", + nodes = { + "default:dirt_with_rainforest_litter", "default:snowblock", + "default:snow", "ethereal:crystal_dirt", "ethereal:cold_dirt" + }, + min_light = 0, + max_light = 8, + chance = 7000, + active_object_count = 1, + min_height = 25, + max_height = 31000, +}) + +-- Spider (below ground) +mobs:spawn({ + name = "mobs_monster:spider", + nodes = {"default:stone_with_mese", "default:mese", "default:stone"}, + min_light = 0, + max_light = 7, + chance = 7000, + active_object_count = 1, + min_height = -31000, + max_height = -40, +}) + +-- Stone Monster + +mobs:spawn({ + name = "mobs_monster:stone_monster", + nodes = {"default:stone", "default:desert_stone", "default:sandstone"}, + max_light = 7, + chance = 7000, + max_height = 0, +}) + +-- Tree Monster + +mobs:spawn({ + name = "mobs_monster:tree_monster", + nodes = {"default:leaves", "default:jungleleaves"}, + max_light = 7, + chance = 7000, + min_height = 0, + day_toggle = false, +}) diff --git a/spider.lua b/spider.lua index 98def91..9cb4ae1 100644 --- a/spider.lua +++ b/spider.lua @@ -178,6 +178,7 @@ mobs:register_mob("mobs_monster:spider", { }) +if not mobs.custom_spawn_monster then -- above ground spawn mobs:spawn({ name = "mobs_monster:spider", @@ -204,6 +205,7 @@ mobs:spawn({ min_height = -31000, max_height = -40, }) +end mobs:register_egg("mobs_monster:spider", S("Spider"), "mobs_cobweb.png", 1) diff --git a/stone_monster.lua b/stone_monster.lua index 876b6f7..34197d7 100644 --- a/stone_monster.lua +++ b/stone_monster.lua @@ -62,6 +62,7 @@ mobs:register_mob("mobs_monster:stone_monster", { }) +if not mobs.custom_spawn_monster then mobs:spawn({ name = "mobs_monster:stone_monster", nodes = {"default:stone", "default:desert_stone", "default:sandstone"}, @@ -69,6 +70,7 @@ mobs:spawn({ chance = 7000, max_height = 0, }) +end mobs:register_egg("mobs_monster:stone_monster", S("Stone Monster"), "default_stone.png", 1) diff --git a/tree_monster.lua b/tree_monster.lua index 039bb72..c1abbea 100644 --- a/tree_monster.lua +++ b/tree_monster.lua @@ -67,6 +67,7 @@ mobs:register_mob("mobs_monster:tree_monster", { }) +if not mobs.custom_spawn_monster then mobs:spawn({ name = "mobs_monster:tree_monster", nodes = {"default:leaves", "default:jungleleaves"}, @@ -75,6 +76,7 @@ mobs:spawn({ min_height = 0, day_toggle = false, }) +end mobs:register_egg("mobs_monster:tree_monster", S("Tree Monster"), "default_tree_top.png", 1)