message.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. }
  65. local function random_str(strs)
  66. return strs[math_random(1, #strs)]
  67. end
  68. local send_chat_world = function(pos, player)
  69. -- Don't spam the message console.
  70. if bones.players[player] then return end
  71. local show_everyone = true
  72. if player_labels.query_nametag_onoff(player) == false then
  73. show_everyone = false
  74. end
  75. if cloaking.is_cloaked(player) then
  76. show_everyone = false
  77. end
  78. if show_everyone then
  79. local dname = rename.gpn(player)
  80. minetest.chat_send_all("# Server: " .. random_str(msg_str1) .. " detected. " ..
  81. "<" .. dname .. "> " .. random_str(msg_str2) .. " at " .. rc.pos_to_namestr(pos) .. ".")
  82. else
  83. minetest.chat_send_all("# Server: " .. random_str(msg_str1) .. " detected. ID and location unknown.")
  84. minetest.chat_send_player(player, "# Server: You died at " .. rc.pos_to_namestr(pos) .. ". The locator beacon was SUPPRESSED.")
  85. end
  86. minetest.chat_send_player(player, "# Server: <" .. rename.gpn(player) .. ">, you may find your bonebox at the above coordinates.")
  87. -- The player can't trigger any more chat messages until released.
  88. bones.players[player] = true
  89. minetest.after(60, release_player, player)
  90. end
  91. bones.do_messages = function(pos, player, num_stacks)
  92. send_chat_world(pos, player)
  93. minetest.log("action", "Player <" .. player .. "> died at (" .. pos.x .. "," .. pos.y .. "," .. pos.z .. "): stackcount=" .. num_stacks)
  94. end