mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 08:29:34 +01:00
Move mob spawner into new mod
This commit is contained in:
parent
d71da3a818
commit
88b02c7170
5 changed files with 16 additions and 12 deletions
3
mods/ENTITIES/mcl_monster_spawner/depends.txt
Normal file
3
mods/ENTITIES/mcl_monster_spawner/depends.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
mobs
|
||||||
|
mobs_mc
|
||||||
|
mcl_sounds
|
|
@ -13,7 +13,7 @@ end
|
||||||
local function find_doll(pos)
|
local function find_doll(pos)
|
||||||
for _,obj in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
|
for _,obj in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
|
||||||
if not obj:is_player() then
|
if not obj:is_player() then
|
||||||
if obj ~= nil and obj:get_luaentity().name == "mobs:spawner_mob_doll" then
|
if obj ~= nil and obj:get_luaentity().name == "mcl_monster_spawner:doll" then
|
||||||
return obj
|
return obj
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -71,11 +71,11 @@ function mobs.setup_spawner(pos, Mob, MinLight, MaxLight, MaxMobsInArea, PlayerD
|
||||||
meta:set_string("command", "")
|
meta:set_string("command", "")
|
||||||
|
|
||||||
-- Create doll
|
-- Create doll
|
||||||
local doll = minetest.add_entity({x=pos.x, y=pos.y-0.3, z=pos.z}, "mobs:spawner_mob_doll")
|
local doll = minetest.add_entity({x=pos.x, y=pos.y-0.3, z=pos.z}, "mcl_monster_spawner:doll")
|
||||||
set_doll_properties(doll, Mob)
|
set_doll_properties(doll, Mob)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("mobs:spawner", {
|
minetest.register_node("mcl_monster_spawner:spawner", {
|
||||||
tiles = {"mob_spawner.png"},
|
tiles = {"mob_spawner.png"},
|
||||||
drawtype = "glasslike",
|
drawtype = "glasslike",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -158,7 +158,7 @@ minetest.register_node("mobs:spawner", {
|
||||||
|
|
||||||
-- Mob spawner doll (rotating icon inside cage)
|
-- Mob spawner doll (rotating icon inside cage)
|
||||||
|
|
||||||
local spawner_mob_doll_def = {
|
local doll_def = {
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = {0,0,0,0,0,0},
|
collisionbox = {0,0,0,0,0,0},
|
||||||
|
@ -170,11 +170,11 @@ local spawner_mob_doll_def = {
|
||||||
_mob = default_mob, -- name of the mob this doll represents
|
_mob = default_mob, -- name of the mob this doll represents
|
||||||
}
|
}
|
||||||
|
|
||||||
spawner_mob_doll_def.get_staticdata = function(self)
|
doll_def.get_staticdata = function(self)
|
||||||
return self._mob
|
return self._mob
|
||||||
end
|
end
|
||||||
|
|
||||||
spawner_mob_doll_def.on_activate = function(self, staticdata, dtime_s)
|
doll_def.on_activate = function(self, staticdata, dtime_s)
|
||||||
local mob = staticdata
|
local mob = staticdata
|
||||||
if mob == "" or mob == nil then
|
if mob == "" or mob == nil then
|
||||||
mob = default_mob
|
mob = default_mob
|
||||||
|
@ -186,20 +186,20 @@ spawner_mob_doll_def.on_activate = function(self, staticdata, dtime_s)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
spawner_mob_doll_def.on_step = function(self, dtime)
|
doll_def.on_step = function(self, dtime)
|
||||||
-- Check if spawner is still present. If not, delete the entity
|
-- Check if spawner is still present. If not, delete the entity
|
||||||
self.timer = self.timer + 0.01
|
self.timer = self.timer + 0.01
|
||||||
local n = minetest.get_node_or_nil(self.object:getpos())
|
local n = minetest.get_node_or_nil(self.object:getpos())
|
||||||
if self.timer > 1 then
|
if self.timer > 1 then
|
||||||
if n and n.name and n.name ~= "mobs:spawner" then
|
if n and n.name and n.name ~= "mcl_monster_spawner:spawner" then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
spawner_mob_doll_def.on_punch = function(self, hitter) end
|
doll_def.on_punch = function(self, hitter) end
|
||||||
|
|
||||||
minetest.register_entity("mobs:spawner_mob_doll", spawner_mob_doll_def)
|
minetest.register_entity("mcl_monster_spawner:doll", doll_def)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ local max_per_block = tonumber(minetest.setting_get("max_objects_per_block") or
|
||||||
-- spawner abm
|
-- spawner abm
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
label = "Monster Spawner spawning a monster",
|
label = "Monster Spawner spawning a monster",
|
||||||
nodenames = {"mobs:spawner"},
|
nodenames = {"mcl_monster_spawner:spawner"},
|
||||||
interval = 10,
|
interval = 10,
|
||||||
chance = 4,
|
chance = 4,
|
||||||
catch_up = false,
|
catch_up = false,
|
1
mods/ENTITIES/mcl_monster_spawner/mod.conf
Normal file
1
mods/ENTITIES/mcl_monster_spawner/mod.conf
Normal file
|
@ -0,0 +1 @@
|
||||||
|
name = mcl_monster_spawner
|
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 261 B |
|
@ -8,7 +8,7 @@ dofile(path .. "/api.lua")
|
||||||
dofile(path .. "/crafts.lua")
|
dofile(path .. "/crafts.lua")
|
||||||
|
|
||||||
-- Mob Spawner
|
-- Mob Spawner
|
||||||
dofile(path .. "/spawner.lua")
|
-- moved into other mod (MCL2 change)
|
||||||
|
|
||||||
-- Lucky Blocks
|
-- Lucky Blocks
|
||||||
dofile(path .. "/lucky_block.lua")
|
dofile(path .. "/lucky_block.lua")
|
||||||
|
|
Loading…
Reference in a new issue