Add /toggle_mobs command
This commit is contained in:
parent
b22dc35568
commit
f8aad7cd4f
@ -21,6 +21,8 @@ local SPAWNER_SLEEP_TIMER = 300
|
||||
-- Special param2 to denote when the spawner is asleep
|
||||
local PARAM2_SLEEP = 255
|
||||
|
||||
-- Whether mobs can spawn
|
||||
local mobs_can_spawn = not EDITOR
|
||||
|
||||
local spawn_mob = function(pos, entitystring)
|
||||
minetest.add_entity(pos, entitystring)
|
||||
@ -47,7 +49,7 @@ local register_mob_spawner = function(id, def)
|
||||
walkable = false,
|
||||
groups = { spawner = 1, editor_breakable = 1 },
|
||||
on_timer = function(pos)
|
||||
if EDITOR then
|
||||
if not mobs_can_spawn then
|
||||
return
|
||||
end
|
||||
if def.limit == 0 then
|
||||
@ -127,7 +129,7 @@ register_mob_spawner("shadow_orb", {
|
||||
|
||||
local spawner_check_timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if EDITOR then
|
||||
if not mobs_can_spawn then
|
||||
return
|
||||
end
|
||||
spawner_check_timer = spawner_check_timer + dtime
|
||||
@ -156,3 +158,16 @@ minetest.register_globalstep(function(dtime)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_chatcommand("toggle_mobs", {
|
||||
description = S("Toggles the spawning of hostile mobs"),
|
||||
privs = { server = true },
|
||||
func = function(name)
|
||||
mobs_can_spawn = not mobs_can_spawn
|
||||
if mobs_can_spawn then
|
||||
return true, S("Mob spawning enabled.")
|
||||
else
|
||||
return false, S("Mob spawning disabled.")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user