message.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. -- This module is responsible for informing players of someone's death.
  2. -- We also inform the dead player where their bones are.
  3. -- We also write a message to the logfile.
  4. bones = bones or {}
  5. bones.players = bones.players or {}
  6. -- Localize for performance.
  7. local math_random = math.random
  8. local release_player = function(player)
  9. if bones.players[player] then
  10. bones.players[player] = nil
  11. end
  12. end
  13. bones.release_player = release_player
  14. local msg_str1 = {
  15. "Blackbox",
  16. "Blackbox",
  17. "Bonebox",
  18. "Bonebox",
  19. "Bonebox",
  20. "Death signal",
  21. "Blackbox signal",
  22. "Bonebox signal",
  23. "Death beacon",
  24. "Blackbox beacon",
  25. "Bonebox beacon",
  26. "Ritual box",
  27. }
  28. local msg_str2 = {
  29. "perished",
  30. "perished",
  31. "perished",
  32. "died",
  33. "died",
  34. "died",
  35. "kicked the bucket",
  36. "kicked the bucket",
  37. "was killed",
  38. "was slain",
  39. "lost a life",
  40. "croaked",
  41. "bit the dust",
  42. "passed away",
  43. "passed on",
  44. "expired",
  45. "expired",
  46. "did something fatal",
  47. "became honestly dead",
  48. "became somewhat dead",
  49. "became mostly dead",
  50. "was involved in a fatal occurrence",
  51. "had a fatal accident",
  52. "is honestly dead",
  53. "is completely dead",
  54. "is mostly dead",
  55. "passed out (permanently)",
  56. "is somewhat dead",
  57. "suffered corporeal malfunction",
  58. "gave up the ghost",
  59. "gave up on life",
  60. "failed survival lessons",
  61. "threw out the book",
  62. "met the grim reaper",
  63. "ended life",
  64. "met a sticky end",
  65. "met a horrid end",
  66. "met a terrifying end",
  67. }
  68. local function random_str(strs)
  69. return strs[math_random(1, #strs)]
  70. end
  71. local send_chat_world = function(pos, player)
  72. -- Don't spam the message console.
  73. if bones.players[player] then return end
  74. local show_everyone = true
  75. if player_labels.query_nametag_onoff(player) == false then
  76. show_everyone = false
  77. end
  78. if cloaking.is_cloaked(player) then
  79. show_everyone = false
  80. end
  81. if show_everyone then
  82. local dname = rename.gpn(player)
  83. minetest.chat_send_all("# Server: " .. random_str(msg_str1) .. " detected. " ..
  84. "<" .. dname .. "> " .. random_str(msg_str2) .. " at " .. rc.pos_to_namestr(pos) .. ".")
  85. else
  86. minetest.chat_send_all("# Server: " .. random_str(msg_str1) .. " detected. ID and location unknown.")
  87. minetest.chat_send_player(player, "# Server: You died at " .. rc.pos_to_namestr(pos) .. ". The locator beacon was SUPPRESSED.")
  88. end
  89. minetest.chat_send_player(player, "# Server: <" .. rename.gpn(player) .. ">, you may find your bonebox at the above coordinates.")
  90. -- The player can't trigger any more chat messages until released.
  91. bones.players[player] = true
  92. minetest.after(60, release_player, player)
  93. end
  94. bones.do_messages = function(pos, player, num_stacks)
  95. send_chat_world(pos, player)
  96. minetest.log("action", "Player <" .. player .. "> died at (" .. pos.x .. "," .. pos.y .. "," .. pos.z .. "): stackcount=" .. num_stacks)
  97. end