From f67191ca37a467c96dec946c81374fef6829930d Mon Sep 17 00:00:00 2001 From: neko259 Date: Sat, 26 Jan 2019 21:04:48 +0200 Subject: [PATCH] If no players are on server, show a separate message instead of reporting an empty list --- commands.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/commands.lua b/commands.lua index 48ef98a..65e2cc0 100644 --- a/commands.lua +++ b/commands.lua @@ -8,11 +8,17 @@ end) telegram.register_command("players", function(msg) local players = "" - for _,player in ipairs(minetest.get_connected_players()) do - local name = player:get_player_name() - players = players .. player:get_player_name() .. ", " + + local player_list = minetest.get_connected_players() + if #player_list > 0 then + for _,player in ipairs(minetest.get_connected_players()) do + local name = player:get_player_name() + players = players .. player:get_player_name() .. ", " + end + telegram.send_message(msg.chat.id, "Active players: " .. players) + else + telegram.send_message(msg.chat.id, "No active players detected." .. players) end - telegram.send_message(msg.chat.id, "Active players: " .. players) end) telegram.register_command("status", function(msg)