entity cramming: clean up check logic
parent
fb4f21cba0
commit
87f50d6423
|
@ -2975,20 +2975,21 @@ local cramming_damage = 3
|
||||||
local function check_entity_cramming(self)
|
local function check_entity_cramming(self)
|
||||||
local p = self.object:get_pos()
|
local p = self.object:get_pos()
|
||||||
local oo = minetest.get_objects_inside_radius(p,1)
|
local oo = minetest.get_objects_inside_radius(p,1)
|
||||||
local clear = false
|
local clear = #oo < entity_cramming_max
|
||||||
if #oo < entity_cramming_max then clear = true end
|
|
||||||
local ncram = {}
|
local ncram = {}
|
||||||
for _,o in pairs(oo) do
|
for _,o in pairs(oo) do
|
||||||
local l = o:get_luaentity()
|
local l = o:get_luaentity()
|
||||||
if l and clear then
|
if l then
|
||||||
|
if clear then
|
||||||
l.cram = nil
|
l.cram = nil
|
||||||
elseif l and l.cram == nil and not self.child then
|
elseif l.cram == nil and not self.child then
|
||||||
table.insert(ncram,l)
|
table.insert(ncram,l)
|
||||||
elseif not clear and l and l.cram then
|
elseif l.cram then
|
||||||
damage_mob(l,"cramming",cramming_damage)
|
damage_mob(l,"cramming",cramming_damage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i,l in ipairs(ncram) do
|
end
|
||||||
|
for i,l in pairs(ncram) do
|
||||||
if i > entity_cramming_max then
|
if i > entity_cramming_max then
|
||||||
l.cram = true
|
l.cram = true
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue