Browse Source

Add player count

master
Ceda EI 8 months ago
parent
commit
149ab033b0
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      chat_mod/init.lua

+ 9
- 1
chat_mod/init.lua View File

@@ -1,10 +1,18 @@
1 1
 local http_api = minetest.request_http_api()
2 2
 
3
+function tablelength(T)
4
+  local count = 0
5
+  for _ in pairs(T) do count = count + 1 end
6
+  return count
7
+end
8
+
3 9
 function send_messages(res)
4 10
 	for message in string.gmatch(res["data"], "[^\n]+") do
5 11
 		if message == "list" then
6 12
 			local x = minetest.get_connected_players()
7
-			local text = "List of Players:\n"
13
+			local text = "List of Players ("
14
+			text = text .. tostring(tablelength(x)) .. "/"
15
+			text = text .. tostring(minetest.settings:get("max_users")) .. "):"
8 16
 			for j, i  in ipairs(x) do
9 17
 				text = text .. "\n" .. i.get_player_name(i)
10 18
 			end

Loading…
Cancel
Save