Add util/

This commit is contained in:
Jean-Patrick Guerrero 2022-01-15 03:12:58 +01:00
parent 2fa971acb4
commit 5e8ecf9903
4 changed files with 37 additions and 7 deletions

View File

@ -18,4 +18,4 @@ jobs:
- name: Setup luacheck
run: luarocks install luacheck
- name: Run luacheck linter
run: lua luacheck.lua .
run: cd util; lua luacheck.lua

View File

@ -2,7 +2,7 @@ local exec = os.execute
local fmt, find, sub = string.format, string.find, string.sub
local var = "[%w%.%[%]\"\'_]"
exec("reset")
exec "clear"
local function split(str, delim, include_empty, max_splits, sep_is_pattern)
delim = delim or ","
@ -121,10 +121,10 @@ for _, p in ipairs(files) do
_file:close()
end
_load("./src/" .. p .. ".lua")
_load("../src/" .. p .. ".lua")
end
exec("luacheck init.lua")
exec("luacheck ./src/operators.lua")
exec("luacheck ./src/*.l")
exec("rm ./src/*.l")
exec "luacheck ../init.lua"
exec "luacheck ../src/operators.lua"
exec "luacheck ../src/*.l"
exec "rm ../src/*.l"

7
util/optipng.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
# Colors with 0 alpha need to be preserved, because opaque leaves ignore alpha.
# For that purpose, the use of indexed colors is disabled (-nc).
cd ../textures
find -name '*.png' -print0 | xargs -0 optipng -o7 -zm1-9 -nc -strip all -clobber

23
util/servers.lua Normal file
View File

@ -0,0 +1,23 @@
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