message.lua 2.6 KB

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