Added "remove_far_mobs" switch to delete mobs out of sight
This commit is contained in:
parent
7a280aad1d
commit
ffc01c35be
18
api.lua
18
api.lua
@ -1,12 +1,13 @@
|
|||||||
-- Mobs Api (1st August 2015)
|
-- Mobs Api (4th August 2015)
|
||||||
mobs = {}
|
mobs = {}
|
||||||
mobs.mod = "redo"
|
mobs.mod = "redo"
|
||||||
|
|
||||||
-- Initial settings check
|
-- Initial settings check
|
||||||
local damage_enabled = minetest.setting_getbool("enable_damage")
|
local damage_enabled = minetest.setting_getbool("enable_damage") or true
|
||||||
local peaceful_only = minetest.setting_getbool("only_peaceful_mobs")
|
local peaceful_only = minetest.setting_getbool("only_peaceful_mobs") or false
|
||||||
local enable_blood = minetest.setting_getbool("mobs_enable_blood") or true
|
local enable_blood = minetest.setting_getbool("mobs_enable_blood") or true
|
||||||
mobs.protected = tonumber(minetest.setting_get("mobs_spawn_protected")) or 0
|
mobs.protected = tonumber(minetest.setting_get("mobs_spawn_protected")) or 0
|
||||||
|
mobs.remove = minetest.setting_getbool("remove_far_mobs") or false
|
||||||
|
|
||||||
function mobs:register_mob(name, def)
|
function mobs:register_mob(name, def)
|
||||||
minetest.register_entity(name, {
|
minetest.register_entity(name, {
|
||||||
@ -1080,6 +1081,8 @@ end
|
|||||||
self.object:set_hp( self.health )
|
self.object:set_hp( self.health )
|
||||||
self.object:set_armor_groups({fleshy = self.armor})
|
self.object:set_armor_groups({fleshy = self.armor})
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
|
self.order = "stand"
|
||||||
|
self.following = nil
|
||||||
self.old_y = self.object:getpos().y
|
self.old_y = self.object:getpos().y
|
||||||
self.object:setyaw(math.random(1, 360) / 180 * math.pi)
|
self.object:setyaw(math.random(1, 360) / 180 * math.pi)
|
||||||
self.sounds.distance = (self.sounds.distance or 10)
|
self.sounds.distance = (self.sounds.distance or 10)
|
||||||
@ -1093,6 +1096,15 @@ end
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
get_staticdata = function(self)
|
get_staticdata = function(self)
|
||||||
|
|
||||||
|
-- remove mob when out of range unless tamed
|
||||||
|
if mobs.remove == true and self.remove_ok and not self.tamed then
|
||||||
|
print ("REMOVED", self.remove_ok, self.name)
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
self.remove_ok = true
|
||||||
|
self.attack = nil
|
||||||
|
|
||||||
local tmp = {}
|
local tmp = {}
|
||||||
for _,stat in pairs(self) do
|
for _,stat in pairs(self) do
|
||||||
local t = type(stat)
|
local t = type(stat)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user