Allow the join/leave message to be overridden by mods.
authorred-001 <red-001@outlook.ie>
Sun, 16 Oct 2016 16:35:07 +0000 (17:35 +0100)
committersfan5 <sfan5@live.de>
Mon, 11 Sep 2017 18:54:07 +0000 (20:54 +0200)
builtin/game/misc.lua
doc/lua_api.txt

index bfe407b9ded146537b3d38a0a1e77cd91eb98632..39ef9b461ce08b3654d5c4595230e8844a940675 100644 (file)
@@ -42,22 +42,30 @@ end
 
 local player_list = {}
 
-core.register_on_joinplayer(function(player)
-       local player_name = player:get_player_name()
-       player_list[player_name] = player
+function core.send_join_message(player_name)
        if not minetest.is_singleplayer() then
                core.chat_send_all("*** " .. player_name .. " joined the game.")
        end
-end)
+end
 
-core.register_on_leaveplayer(function(player, timed_out)
-       local player_name = player:get_player_name()
-       player_list[player_name] = nil
+function core.send_leave_message(player_name, timed_out)
        local announcement = "*** " ..  player_name .. " left the game."
        if timed_out then
                announcement = announcement .. " (timed out)"
        end
        core.chat_send_all(announcement)
+end
+
+core.register_on_joinplayer(function(player)
+       local player_name = player:get_player_name()
+       player_list[player_name] = player
+       core.send_join_message(player_name)
+end)
+
+core.register_on_leaveplayer(function(player, timed_out)
+       local player_name = player:get_player_name()
+       player_list[player_name] = nil
+       core.send_leave_message(player_name, timed_out)
 end)
 
 function core.get_connected_players()
index ef62f1356845cf64aa37cd85f1d51103f8690238..6bdb63ef3008b88e7cc743f2c166bef7bfed3780 100644 (file)
@@ -3071,6 +3071,10 @@ These functions return the leftover itemstack.
     * Replaces definition of a builtin hud element
     * `name`: `"breath"` or `"health"`
     * `hud_definition`: definition to replace builtin definition
+* `minetest.send_join_message(player_name)`
+    * Can be overridden by mods to change the join message
+* `minetest.send_leave_message(player_name, timed_out)`
+    * Can be overridden by mods to change the leave message
 * `minetest.hash_node_position({x=,y=,z=})`: returns an 48-bit integer
     * Gives a unique hash number for a node position (16+16+16=48bit)
 * `minetest.get_position_from_hash(hash)`: returns a position