init.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. -- support for MT game translation.
  2. local S = default.get_translator
  3. local enabled = true
  4. if minetest.settings:get("death_announce") == "false" then
  5. enabled = false
  6. end
  7. if enabled then
  8. minetest.register_on_dieplayer(function(player, reason)
  9. local message = ""
  10. if reason.type == "punch" and reason.object:is_player() then
  11. message = player:get_player_name() .. " " .. S("were killed by") .. " " .. reason.object:get_player_name() .. "."
  12. elseif reason.type == "punch" then
  13. local hiters_name = reason.object:get_entity_name()
  14. local monsters_egg = minetest.registered_items[hiters_name]
  15. if monsters_egg ~= nil then
  16. message = player:get_player_name() .. " " .. S("were killed by") .. " " .. monsters_egg.description .. "."
  17. else
  18. local projectiles_name = string.gsub (string.sub(hiters_name, string.find(hiters_name, ":") + 1, string.len(hiters_name)), "_", " ")
  19. message = player:get_player_name() .. " " .. S("were killed by") .. " " .. projectiles_name .. "."
  20. end
  21. elseif reason.type == "fall" then
  22. message = player:get_player_name() .. " " .. S("fell from too high") .. "."
  23. else
  24. message = player:get_player_name() .. " " .. S("died") .. "."
  25. end
  26. minetest.chat_send_all(message)
  27. end)
  28. end