minetest-i4/i4/util/servers.lua
Jaidyn Ann e49a197fc3 Add conversion mod to transfer data from i3→14
This makes i4 a modpack; files have been moved correspondingly.
2024-01-12 13:18:10 -06:00

24 lines
580 B
Lua

local JSON = require"JSON" -- luarocks install json-lua
os.execute "clear"
local list = io.popen("curl -s -H 'Accept: text/html' http://servers.minetest.net/list"):read("*a")
list = JSON:decode(list).list
local servers = {}
for _, server in ipairs(list) do
if server.mods then
for _, mod in ipairs(server.mods) do
if mod == "i3" then
table.insert(servers, server.name)
end
end
end
end
if #servers > 0 then
print(("=> %u/%u servers using [i3]:\n\t• %s"):format(#servers, #list, table.concat(servers, "\n\t")))
else
print"No server using [i3]"
end