From 5e8ecf990368bce5ca598d9a83aa7bee084f9fe1 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sat, 15 Jan 2022 03:12:58 +0100 Subject: [PATCH] Add util/ --- .github/workflows/luacheck.yml | 2 +- luacheck.lua => util/luacheck.lua | 12 ++++++------ util/optipng.sh | 7 +++++++ util/servers.lua | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 7 deletions(-) rename luacheck.lua => util/luacheck.lua (94%) create mode 100644 util/optipng.sh create mode 100644 util/servers.lua diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml index 32ded65..d9d6abf 100644 --- a/.github/workflows/luacheck.yml +++ b/.github/workflows/luacheck.yml @@ -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 diff --git a/luacheck.lua b/util/luacheck.lua similarity index 94% rename from luacheck.lua rename to util/luacheck.lua index e86d4ba..141e18b 100755 --- a/luacheck.lua +++ b/util/luacheck.lua @@ -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" diff --git a/util/optipng.sh b/util/optipng.sh new file mode 100644 index 0000000..4e59b44 --- /dev/null +++ b/util/optipng.sh @@ -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 diff --git a/util/servers.lua b/util/servers.lua new file mode 100644 index 0000000..abd06a7 --- /dev/null +++ b/util/servers.lua @@ -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