Cleanup and removed debug prints.

This commit is contained in:
CyberMango 2023-01-05 23:51:10 +02:00
parent cd63f32cdd
commit 96cd2657db

@ -1,6 +1,6 @@
local S = minetest.get_translator(minetest.get_current_modname())
ASSIST_TIMEOUT_SEC = 10
ASSIST_TIMEOUT_SEC = 5
mcl_death_messages = {
assist = {},
@ -151,11 +151,6 @@ mcl_death_messages = {
plain = "@1 went off with a bang",
item = "@1 went off with a bang due to a firework fired from @3 by @2", -- order is intentional
},
sweet_berry = {
_translator = S,
plain = "@1 died a sweet death",
assist = "@1 was poked to death by a sweet berry bush whilst trying to escape @2",
},
-- Missing snowballs: The Minecraft wiki mentions them but the MC source code does not.
},
}
@ -185,14 +180,8 @@ end
local function get_assist_message(obj, messages, reason)
-- Avoid a timing issue if the assist passes its timeout.
local assist_details = mcl_death_messages.assist[obj]
if messages.assist then
print("TODO message.assist exists!")--TODO make this 1 condition again
if assist_details then
print("TODO There is an assist message object!")--TODO
return messages._translator(messages.assist, mcl_util.get_object_name(obj), assist_details.name)
end
else--TODO remove this else
print("TODO There was no assist message!")
if messages.assist and assist_details then
return messages._translator(messages.assist, mcl_util.get_object_name(obj), assist_details.name)
end
end
@ -234,9 +223,6 @@ mcl_damage.register_on_death(function(obj, reason)
get_fallback_message(obj, messages, reason)
if send_to == true then
if not message or message == "" then
message = "there was not message"
end
minetest.chat_send_all(message)
else
minetest.chat_send_player(send_to, message)
@ -245,19 +231,15 @@ mcl_damage.register_on_death(function(obj, reason)
end)
mcl_damage.register_on_damage(function(obj, damage, reason)
print("TODO ", reason.type .. " caused damage ")
if obj:get_hp() - damage > 0 then
if reason.source then
print("TODO reason had a source")
-- To avoid timing issues we cancel the previous job before adding a new one.
if mcl_death_messages.assist[obj] then
print("TODO job is being caceled")
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()
print("TODO in job")
mcl_death_messages.assist[obj] = nil
end)
mcl_death_messages.assist[obj] = {name = mcl_util.get_object_name(reason.source), job = new_job}