Fix mob spawner icon not shown in gen'd spawners

This commit is contained in:
Wuzzy 2017-05-25 07:34:53 +02:00
parent f676a2fc2c
commit 0d6b57c9c4

View File

@ -23,6 +23,10 @@ local function find_doll(pos)
return nil
end
local function spawn_doll(pos)
return minetest.add_entity({x=pos.x, y=pos.y-0.3, z=pos.z}, "mcl_mobspawners:doll")
end
local function set_doll_properties(doll, mob)
local mobinfo = minetest.registered_entities[mob]
local prop = {
@ -69,9 +73,10 @@ function mcl_mobspawners.setup_spawner(pos, Mob, MinLight, MaxLight, MaxMobsInAr
meta:set_int("YOffset", YOffset)
-- Create doll
local doll = minetest.add_entity({x=pos.x, y=pos.y-0.3, z=pos.z}, "mcl_mobspawners:doll")
local doll = spawn_doll(pos)
set_doll_properties(doll, Mob)
-- Start spawning very soon
local t = minetest.get_node_timer(pos)
t:start(2)
@ -135,6 +140,19 @@ local spawn_monsters = function(pos, elapsed)
end
end
--[[ HACK!
The doll may not stay spawned if the monster spawner is placed far away from
players, so we will check for its existance periodically when a player is nearby.
This would happen almost always when the monster spawner is placed by the mapgen.
FIXME: Find out why the doll does not seem to spawn / despawns immediately when
monster spawner is placed by mapgen.
]]
local doll = find_doll(pos)
if not doll then
doll = spawn_doll(pos)
set_doll_properties(doll, mob)
end
-- count mob objects of same type in area
for k, obj in ipairs(objs) do