diff options
author | Xunto <xunto@users.noreply.github.com> | 2016-08-22 22:21:48 +0400 |
---|---|---|
committer | est31 <est31@users.noreply.github.com> | 2016-08-22 20:21:48 +0200 |
commit | 0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42 (patch) | |
tree | 475909f119c73fb68acb91b401173eb838b58471 /builtin/game/misc.lua | |
parent | cafa400fa5077e7cb9c627d79482941cb82a81cf (diff) | |
download | minetest-0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42.tar.gz minetest-0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42.tar.bz2 minetest-0b0075e6ad0b3110cabdfc92cedb0a24d2b5ec42.zip |
Move on join and on leave messages to lua (#4460)
Diffstat (limited to 'builtin/game/misc.lua')
-rw-r--r-- | builtin/game/misc.lua | 14 |
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() |