add custom spawn check and examples

This commit is contained in:
tenplus1 2024-08-16 18:03:24 +01:00
parent 528cd204b3
commit 9e3d06586e
6 changed files with 154 additions and 62 deletions

View File

@ -53,19 +53,26 @@ mobs:register_mob("mobs_bat:bat", {
end
})
-- spawn in world
-- Check for custom spawn.lua
mobs:spawn({
name = "mobs_bat:bat",
nodes = {"air"},
neighbors = l_spawnnear,
max_light = 6,
interval = 30,
chance = l_spawnchance,
active_object_count = 2,
min_height = -100,
max_height = 150
})
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_bat:bat",
nodes = {"air"},
neighbors = l_spawnnear,
max_light = 6,
interval = 30,
chance = l_spawnchance,
active_object_count = 2,
min_height = -100,
max_height = 150
})
end
-- mob egg

View File

@ -0,0 +1,14 @@
-- Bat spawn example
mobs:spawn({
name = "mobs_bat:bat",
nodes = {"air"},
neighbors = {"default:stone"},
max_light = 6,
interval = 30,
chance = 30000,
active_object_count = 2,
min_height = -100,
max_height = 150
})

View File

@ -1,6 +0,0 @@
-- SETTINGS
ENABLE_GULLS = true
ENABLE_LARGE_BIRDS = true
ENABLE_SMALL_BIRDS = true

View File

@ -1,18 +1,20 @@
-- local variables
local l_spawn_chance_gull = 24000
local l_spawn_chance_bird = 36000
local l_spawn_chance_gull = 24000
local l_spawn_chance_bird = 36000
-- load settings
dofile(minetest.get_modpath("mobs_birds") .. "/SETTINGS.txt")
local ENABLE_GULLS = minetest.settings:get_bool("mobs_birds.enable_gulls") ~= false
local ENABLE_LARGE = minetest.settings:get_bool("mobs_birds.enable_large_birds") ~= false
local ENABLE_SMALL = minetest.settings:get_bool("mobs_birds.enable_small_birds") ~= false
if not ENABLE_LARGE_BIRDS then
if not ENABLE_LARGE then
l_spawn_chance_bird = l_spawn_chance_bird - 18000
end
if not ENABLE_SMALL_BIRDS then
if not ENABLE_SMALL then
l_spawn_chance_bird = l_spawn_chance_bird - 18000
end
@ -63,23 +65,12 @@ if ENABLE_GULLS then
end
})
mobs:spawn({
name = "mobs_birds:gull",
nodes = {"air"},
neighbors = {"group:water"},
max_light = 5,
interval = 30,
chance = l_spawn_chance_gull,
min_height = 0,
max_height = 200
})
mobs:register_egg("mobs_birds:gull", "Gull", "default_cloud.png", 1)
end
-- large birds
if ENABLE_LARGE_BIRDS then
if ENABLE_LARGE then
mobs:register_mob("mobs_birds:bird_lg", {
type = "animal",
@ -122,25 +113,12 @@ if ENABLE_LARGE_BIRDS then
end
})
mobs:spawn({
name = "mobs_birds:bird_lg",
nodes = {"air"},
neighbors = {
"group:leaves" , (mod_mcl and "mcl_core:cactus" or "default:cactus")
},
max_light = 5,
interval = 30,
chance = l_spawn_chance_bird,
min_height = 0,
max_height = 200
})
mobs:register_egg("mobs_birds:bird_lg", "Large bird", "default_cloud.png", 1)
end
-- small birds
if ENABLE_SMALL_BIRDS then
if ENABLE_SMALL then
mobs:register_mob("mobs_birds:bird_sm", {
type = "animal",
@ -183,20 +161,62 @@ if ENABLE_SMALL_BIRDS then
end
})
mobs:spawn({
name = "mobs_birds:bird_sm",
nodes = {"air"},
neighbors = {
"group:leaves" , (mod_mcl and "mcl_core:cactus" or "default:cactus")
},
max_light = 5,
interval = 30,
chance = l_spawn_chance_bird,
min_height = 0,
max_height = 200
})
mobs:register_egg("mobs_birds:bird_sm", "Small bird", "default_cloud.png", 1)
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_GULL then
mobs:spawn({
name = "mobs_birds:gull",
nodes = {"air"},
neighbors = {"group:water"},
max_light = 5,
interval = 30,
chance = l_spawn_chance_gull,
min_height = 0,
max_height = 200
})
end
if ENABLE_SMALL then
mobs:spawn({
name = "mobs_birds:bird_sm",
nodes = {"air"},
neighbors = {
"group:leaves" , (mod_mcl and "mcl_core:cactus" or "default:cactus")
},
max_light = 5,
interval = 30,
chance = l_spawn_chance_bird,
min_height = 0,
max_height = 200
})
end
if ENABLE_LARGE then
mobs:spawn({
name = "mobs_birds:bird_lg",
nodes = {"air"},
neighbors = {
"group:leaves" , (mod_mcl and "mcl_core:cactus" or "default:cactus")
},
max_light = 5,
interval = 30,
chance = l_spawn_chance_bird,
min_height = 0,
max_height = 200
})
end
end
print("[MOD] Mobs Redo Birds loaded")

3
mobs_birds/settingtypes.txt Executable file
View File

@ -0,0 +1,3 @@
mobs_birds.enable_gulls (Enable Gulls) bool true
mobs_birds.enable_large_birds (Enable Large Birds) bool true
mobs_birds.enable_small_birds (Enable Small Birds bool true

View File

@ -0,0 +1,54 @@
-- load settings
local ENABLE_GULLS = minetest.settings:get_bool("mobs_birds.enable_gulls") ~= false
local ENABLE_LARGE = minetest.settings:get_bool("mobs_birds.enable_large_birds") ~= false
local ENABLE_SMALL = minetest.settings:get_bool("mobs_birds.enable_small_birds") ~= false
-- Custom spawn examples
if ENABLE_GULL then
mobs:spawn({
name = "mobs_birds:gull",
nodes = {"air"},
neighbors = {"group:water"},
max_light = 5,
interval = 30,
chance = 24000,
min_height = 0,
max_height = 200
})
end
if ENABLE_SMALL then
mobs:spawn({
name = "mobs_birds:bird_sm",
nodes = {"air"},
neighbors = {
"group:leaves" , (mod_mcl and "mcl_core:cactus" or "default:cactus")
},
max_light = 5,
interval = 30,
chance = 18000,
min_height = 0,
max_height = 200
})
end
if ENABLE_LARGE then
mobs:spawn({
name = "mobs_birds:bird_lg",
nodes = {"air"},
neighbors = {
"group:leaves" , (mod_mcl and "mcl_core:cactus" or "default:cactus")
},
max_light = 5,
interval = 30,
chance = 18000,
min_height = 0,
max_height = 200
})
end