mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-24 20:03:45 +01:00
Mixed 2 conditions into 1.
This commit is contained in:
parent
a1d98c080f
commit
06435e0f4c
@ -231,18 +231,17 @@ mcl_damage.register_on_death(function(obj, reason)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
mcl_damage.register_on_damage(function(obj, damage, reason)
|
mcl_damage.register_on_damage(function(obj, damage, reason)
|
||||||
if obj:get_hp() - damage > 0 then
|
if (obj:get_hp() - damage > 0) and reason.source and
|
||||||
if reason.source and (reason.source:is_player() or obj:get_luaentity()) then
|
(reason.source:is_player() or obj:get_luaentity()) then
|
||||||
-- To avoid timing issues we cancel the previous job before adding a new one.
|
-- To avoid timing issues we cancel the previous job before adding a new one.
|
||||||
if mcl_death_messages.assist[obj] then
|
if mcl_death_messages.assist[obj] then
|
||||||
mcl_death_messages.assist[obj].job:cancel()
|
mcl_death_messages.assist[obj].job:cancel()
|
||||||
end
|
|
||||||
|
|
||||||
-- Add a new assist object with a timeout job.
|
|
||||||
local new_job = minetest.after(ASSIST_TIMEOUT_SEC, function()
|
|
||||||
mcl_death_messages.assist[obj] = nil
|
|
||||||
end)
|
|
||||||
mcl_death_messages.assist[obj] = {name = mcl_util.get_object_name(reason.source), job = new_job}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Add a new assist object with a timeout job.
|
||||||
|
local new_job = minetest.after(ASSIST_TIMEOUT_SEC, function()
|
||||||
|
mcl_death_messages.assist[obj] = nil
|
||||||
|
end)
|
||||||
|
mcl_death_messages.assist[obj] = {name = mcl_util.get_object_name(reason.source), job = new_job}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user