aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorXunto <xunto@users.noreply.github.com>2016-08-22 22:21:48 +0400
committerest31 <est31@users.noreply.github.com>2016-08-22 20:21:48 +0200
commit0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42 (patch)
tree475909f119c73fb68acb91b401173eb838b58471 /builtin
parentcafa400fa5077e7cb9c627d79482941cb82a81cf (diff)
downloadminetest-0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42.tar.gz
minetest-0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42.tar.bz2
minetest-0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42.zip
Move on join and on leave messages to lua (#4460)
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/misc.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua
index 4773e0012..d7164812a 100644
--- a/builtin/game/misc.lua
+++ b/builtin/game/misc.lua
@@ -87,11 +87,19 @@ end
local player_list = {}
core.register_on_joinplayer(function(player)
- player_list[player:get_player_name()] = player
+ local player_name = player:get_player_name()
+ player_list[player_name] = player
+ core.chat_send_all("*** " .. player_name .. " joined the game.")
end)
-core.register_on_leaveplayer(function(player)
- player_list[player:get_player_name()] = nil
+core.register_on_leaveplayer(function(player, timed_out)
+ local player_name = player:get_player_name()
+ player_list[player_name] = nil
+ local announcement = "*** " .. player_name .. " left the game."
+ if timed_out then
+ announcement = announcement .. " (timed out)"
+ end
+ core.chat_send_all(announcement)
end)
function core.get_connected_players()