Added spawn.lua check for custom mob spawning with example file

This commit is contained in:
tenplus1 2020-09-21 09:48:45 +01:00
parent e8ccc6b3c1
commit 95c32cb4af
12 changed files with 249 additions and 17 deletions

View File

@ -46,6 +46,7 @@ mobs:register_mob("mobs_animal:bee", {
-- end,
})
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:bee",
nodes = {"group:flower"},
@ -56,6 +57,7 @@ mobs:spawn({
max_height = 200,
day_toggle = true,
})
end
mobs:register_egg("mobs_animal:bee", S("Bee"), "mobs_bee_inv.png")

View File

@ -113,6 +113,7 @@ if minetest.get_modpath("ethereal") then
spawn_on = "ethereal:prairie_dirt"
end
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:bunny",
nodes = {spawn_on},
@ -124,6 +125,7 @@ mobs:spawn({
max_height = 200,
day_toggle = true,
})
end
mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0)

View File

@ -100,6 +100,8 @@ if minetest.get_modpath("ethereal") then
spawn_on = {"ethereal:bamboo_dirt", "ethereal:prairie_dirt"}
end
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:chicken",
nodes = spawn_on,
@ -111,6 +113,7 @@ mobs:spawn({
max_height = 200,
day_toggle = true,
})
end
mobs:register_egg("mobs_animal:chicken", S("Chicken"), "mobs_chicken_inv.png", 0)

View File

@ -135,6 +135,7 @@ mobs:register_mob("mobs_animal:cow", {
})
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:cow",
nodes = {"default:dirt_with_grass", "ethereal:green_dirt"},
@ -146,6 +147,7 @@ mobs:spawn({
max_height = 200,
day_toggle = true,
})
end
mobs:register_egg("mobs_animal:cow", S("Cow"), "mobs_cow_inv.png")

View File

@ -1,23 +1,44 @@
-- 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_animal") 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_animal = true
input:close()
input = nil
end
-- Animals
dofile(path .. "/chicken.lua") -- JKmurray
dofile(path .. "/cow.lua") -- KrupnoPavel
dofile(path .. "/rat.lua") -- PilzAdam
dofile(path .. "/sheep.lua") -- PilzAdam
dofile(path .. "/warthog.lua") -- KrupnoPavel
dofile(path .. "/bee.lua") -- KrupnoPavel
dofile(path .. "/bunny.lua") -- ExeterDad
dofile(path .. "/kitten.lua") -- Jordach/BFD
dofile(path .. "/penguin.lua") -- D00Med
dofile(path .. "/panda.lua") -- AspireMint
dofile(path .. "chicken.lua") -- JKmurray
dofile(path .. "cow.lua") -- KrupnoPavel
dofile(path .. "rat.lua") -- PilzAdam
dofile(path .. "sheep.lua") -- PilzAdam
dofile(path .. "warthog.lua") -- KrupnoPavel
dofile(path .. "bee.lua") -- KrupnoPavel
dofile(path .. "bunny.lua") -- ExeterDad
dofile(path .. "kitten.lua") -- Jordach/BFD
dofile(path .. "penguin.lua") -- D00Med
dofile(path .. "panda.lua") -- AspireMint
-- Load custom spawning
if mobs.custom_spawn_animal then
dofile(path .. "spawn.lua")
end
-- Lucky Blocks
dofile(path .. "/lucky_block.lua")
dofile(path .. "lucky_block.lua")
print (S("[MOD] Mobs Redo Animals loaded"))

View File

@ -115,6 +115,7 @@ if minetest.get_modpath("ethereal") then
spawn_on = "ethereal:grove_dirt"
end
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:kitten",
nodes = {spawn_on},
@ -126,6 +127,7 @@ mobs:spawn({
max_height = 50,
day_toggle = true,
})
end
mobs:register_egg("mobs_animal:kitten", S("Kitten"), "mobs_kitten_inv.png", 0)

View File

@ -68,7 +68,7 @@ stepheight = 0.6,
end,
})
if minetest.get_modpath("ethereal") then
if minetest.get_modpath("ethereal") and not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:panda",

View File

@ -60,7 +60,7 @@ stepheight = 0.6,
end,
})
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:penguin",
nodes = {"default:snowblock"},
@ -71,6 +71,6 @@ mobs:spawn({
max_height = 200,
day_toggle = true,
})
end
mobs:register_egg("mobs_animal:penguin", S("Penguin"), "mobs_penguin_inv.png")

View File

@ -67,6 +67,7 @@ local function rat_spawn(self, pos)
self.health = 100
end
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:rat",
nodes = {"default:stone"},
@ -77,6 +78,7 @@ mobs:spawn({
max_height = 0,
-- on_spawn = rat_spawn,
})
end
mobs:register_egg("mobs_animal:rat", S("Rat"), "mobs_rat_inv.png")

View File

@ -207,6 +207,7 @@ mobs:register_egg("mobs_animal:sheep_"..col[1], S("@1 Sheep", col[2]), "wool_"..
end
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:sheep_white",
nodes = {"default:dirt_with_grass", "ethereal:green_dirt"},
@ -218,6 +219,7 @@ mobs:spawn({
max_height = 200,
day_toggle = true,
})
end
mobs:alias_mob("mobs:sheep", "mobs_animal:sheep_white") -- compatibility

195
spawn_example.lua Normal file
View File

@ -0,0 +1,195 @@
--[[ 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
})
]]--
-- Bee
mobs:spawn({
name = "mobs_animal:bee",
nodes = {"group:flower"},
min_light = 14,
interval = 60,
chance = 7000,
min_height = 3,
max_height = 200,
day_toggle = true,
})
-- Bunny
mobs:spawn({
name = "mobs_animal:bunny",
nodes = {"default:dirt_with_grass"},
neighbors = {"group:grass"},
min_light = 14,
interval = 60,
chance = 8000,
min_height = 5,
max_height = 200,
day_toggle = true,
})
-- Chicken
mobs:spawn({
name = "mobs_animal:chicken",
nodes = {"default:dirt_with_grass"},
neighbors = {"group:grass"},
min_light = 14,
interval = 60,
chance = 8000,
min_height = 5,
max_height = 200,
day_toggle = true,
})
-- Cow
mobs:spawn({
name = "mobs_animal:cow",
nodes = {"default:dirt_with_grass", "ethereal:green_dirt"},
neighbors = {"group:grass"},
min_light = 14,
interval = 60,
chance = 8000,
min_height = 5,
max_height = 200,
day_toggle = true,
})
-- Kitten
mobs:spawn({
name = "mobs_animal:kitten",
nodes = {"default:dirt_with_grass"},
neighbors = {"group:grass"},
min_light = 14,
interval = 60,
chance = 10000,
min_height = 5,
max_height = 50,
day_toggle = true,
})
-- Panda
mobs:spawn({
name = "mobs_animal:panda",
nodes = {"ethereal:bamboo_dirt"},
neighbors = {"group:grass"},
min_light = 14,
interval = 60,
chance = 8000,
min_height = 10,
max_height = 80,
day_toggle = true,
})
-- Penguin
mobs:spawn({
name = "mobs_animal:penguin",
nodes = {"default:snowblock"},
min_light = 14,
interval = 60,
chance = 20000,
min_height = 0,
max_height = 200,
day_toggle = true,
})
-- Rat
mobs:spawn({
name = "mobs_animal:rat",
nodes = {"default:stone"},
min_light = 3,
max_light = 9,
interval = 60,
chance = 8000,
max_height = 0,
})
-- Sheep
mobs:spawn({
name = "mobs_animal:sheep_white",
nodes = {"default:dirt_with_grass", "ethereal:green_dirt"},
neighbors = {"group:grass"},
min_light = 14,
interval = 60,
chance = 8000,
min_height = 0,
max_height = 200,
day_toggle = true,
})
-- Warthog
mobs:spawn({
name = "mobs_animal:pumba",
nodes = {"default:dirt_with_dry_grass", "default:dry_dirt_with_dry_grass"},
neighbors = {"group:dry_grass"},
min_light = 14,
interval = 60,
chance = 8000,
min_height = 0,
max_height = 200,
day_toggle = true,
})

View File

@ -72,6 +72,7 @@ if minetest.get_modpath("ethereal") then
spawn_by = {"flowers:mushroom_brown", "flowers:mushroom_red"}
end
if not mobs.custom_spawn_animal then
mobs:spawn({
name = "mobs_animal:pumba",
nodes = spawn_on,
@ -83,7 +84,7 @@ mobs:spawn({
max_height = 200,
day_toggle = true,
})
end
mobs:register_egg("mobs_animal:pumba", S("Warthog"), "mobs_pumba_inv.png")