Scripts¶
Warning
Contents of this article are outdated.
This article was migrated from the old Mineclonia repo wiki and was last updated on July 18, 2024. Once it’s actualized, this note should be removed.
Side-by-side PP/MC texture comparison¶
#!/bin/sh
# needs imagemagick's montage (apt install imagemagick)
path_to_pp=~/var/src/MT/PixelPerfection #https://resourcepack.net/pixel-perfection-resource-pack
path_to_mc=~/var/src/MT/MineCraft #https://texture-packs.com/resourcepack/default-pack/
path_to_sbs=~/var/src/ppmc
mkdir -p $path_to_sbs
cd $path_to_pp/assets/minecraft/textures/block
for f in *.png; do
ff=$path_to_mc/assets/minecraft/textures/block/$f;
if [ -f $ff ]; then
montage $f $ff -tile 2x1 -geometry +0+0 $path_to_sbs/$f;
fi;
done
List all PRs since MCL2 release¶
#!/bin/sh
# create a markdown list of all PRs since mcl2 release (or since issueid)
release=3644 #issue id of mcl2 release
git ls-remote mcl2 'pull/*/head' |grep "pull/$release" -A 500000 |cut -d '/' -f 3 | while read pr; do
l="https://git.minetest.land/MineClone2/MineClone2/pulls/$pr";
p=$(curl -s $l);
if [ "$(echo $p|grep merged)" != "" ]; then
echo "- [ ] " $l $(echo $p|grep "<title>"|sed 's/<title>//;s/<\/title>//')|sed 's/ - MineClone2 - Mesehub$//';
fi;
done
Print superfluous fields in node definitions¶
-- put at the end of builtin/game/register.lua to print superfluous fields in node defs
local old_rn = minetest.register_node
function minetest.register_node(name, def)
local same = {}
local same_found = false
for k, v in pairs(def) do
if type(v) ~= "table" and type(v) ~= "function" then
if v == core.nodedef_default[k] and k ~= "type" then --type often gets copied when modified nodes are made from existing defs
same[k] = v
same_found = true
end
end
end
if same_found then
print("superfluous node def fields for "..tostring(name)..":")
print(dump(same))
end
return old_rn(name, def)
end
Calculate code size difference between MCLA and VL¶
#!/bin/sh
# Difference in code size between mcla and mcl2
mcla_path=$1
mcl2_path=$2
if [ ! -d ${mcla_path}/mods ] || [ ! -d ${mcl2_path}/mods ]; then echo "Usage: $0 mcla_path mcl2_path"; exit; fi
mcla_lines=$(find ${mcla_path}/mods -name "*.lua"|xargs cat |wc -l)
mcla_bytes=$(find ${mcla_path}/mods -name "*.lua"|xargs cat |wc -c)
mcl2_lines=$(find ${mcl2_path}/mods -name "*.lua"|xargs cat |wc -l)
mcl2_bytes=$(find ${mcl2_path}/mods -name "*.lua"|xargs cat |wc -c)
echo "# Code size difference of mcla and mcl2"
echo "## loc"
echo lua lines in mcl2: $mcl2_lines
echo lua lines in mcla: $mcla_lines
echo -n difference:; echo "$mcl2_lines - $mcla_lines" |bc
echo mcla is $(echo "$mcla_lines / $mcl2_lines * 100" |bc -l |head -c5)\% of mcl2
echo "## bytes"
echo lua bytes in mcl2: $mcl2_bytes
echo lua bytes in mcla: $mcla_bytes
echo -n difference:; echo "$mcl2_bytes - $mcla_bytes" |bc
echo mcla is $(echo "$mcla_bytes / $mcl2_bytes * 100" |bc -l|head -c5)\% of mcl2