forked from VoxeLibre/VoxeLibre
Add direct mob spawn api command + chat command
This commit is contained in:
parent
c54a60fedf
commit
fa47f7cf06
|
@ -444,8 +444,26 @@ minetest.register_chatcommand("mobstats",{
|
|||
end
|
||||
})
|
||||
|
||||
if mobs_spawn then
|
||||
minetest.register_chatcommand("spawn_mob",{
|
||||
privs = { debug = true },
|
||||
func = function(n,param)
|
||||
local pos = minetest.get_player_by_name(n):get_pos()
|
||||
if mcl_mobs.spawn(pos,param) then
|
||||
return true, param.." spawned at "..minetest.pos_to_string(pos)
|
||||
end
|
||||
return false, "Couldn't spawn "..param
|
||||
end
|
||||
})
|
||||
|
||||
function mcl_mobs.spawn(pos,id)
|
||||
local def = minetest.registered_entities[id] or minetest.registered_entities["mobs_mc:"..id] or minetest.registered_entities["extra_mobs:"..id]
|
||||
if not def or (def.can_spawn and not minetest.registered_entities[id].can_spawn(pos) ) or not def.is_mob then
|
||||
return false
|
||||
end
|
||||
return minetest.add_entity(pos, def.name)
|
||||
end
|
||||
|
||||
if mobs_spawn then
|
||||
local perlin_noise
|
||||
|
||||
local function spawn_a_mob(pos, dimension, y_min, y_max)
|
||||
|
@ -541,10 +559,9 @@ if mobs_spawn then
|
|||
local object
|
||||
if spawn_in_group then
|
||||
object = spawn_group(spawning_position,mob_def,{gotten_node},spawn_in_group,spawn_in_group_min)
|
||||
else object = minetest.add_entity(spawning_position, mob_def.name)
|
||||
else object = mcl_mobs.spawn(pos,mob_def.name)
|
||||
end
|
||||
|
||||
|
||||
if object then
|
||||
return mob_def.on_spawn and mob_def.on_spawn(object, spawning_position)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue