more robust script, some more colors

This commit is contained in:
Florian Schüller
2016-07-13 23:37:01 +02:00
parent 2aa8619777
commit 7e864b36bf
2 changed files with 2335 additions and 13 deletions

View File

@ -97,19 +97,28 @@ if counted == 0:
cl = tuple(int(n / counted) for n in cl) cl = tuple(int(n / counted) for n in cl)
print("%d %d %d" % cl) print("%d %d %d" % cl)
==SCRIPT== ==SCRIPT==
#!/bin/bash -e #!/bin/bash
AVGCOLOR_PATH=/path/to/avgcolor.py AVGCOLOR_PATH=avgcolor.py
MTGAME_PATH=/path/to/minetest_game MTGAME_PATH=/usr/share/games/minetest
NODESTXT_PATH=./nodes.txt MTGAME_ALT_PATH=~/.minetest/mods
COLORSTXT_PATH=./colors.txt NODESTXT_PATH=~/.minetest/mods/dumpnodes/nodes.txt
COLORSTXT_PATH=colors.txt
while read -r p; do while read -r p; do
set -- junk $p set -- junk $p
shift shift
if [[ ! $1 == "#" && ! $1 == "" ]]; then if [[ ! $1 == "#" && ! $1 == "" && ! $2 == "" ]]; then
echo $1 `python $AVGCOLOR_PATH $(find $MTGAME_PATH -type f -name $2)` #don't know why there is a bracket sometimes...
SEARCH_FILE=$(echo $2 | tr -d "(")
FILENAME=$(find $MTGAME_PATH $MTGAME_ALT_PATH -type f -name $SEARCH_FILE|head -n1)
if [ -f "$FILENAME" ]; then
COLOR=$(python $AVGCOLOR_PATH $FILENAME)
echo $1 $COLOR
echo $1 1>&2 echo $1 1>&2
else
echo "Skipping $2 (didn't find it)" >&2
fi
else else
echo "$p" echo "$p"
fi fi
@ -122,6 +131,7 @@ sed -re 's/^default:(.*glass) ([0-9 ]+)$/default:\1 \2 64 16/g' $COLORSTXT_PATH
sed -re 's/^doors:(.*glass[^ ]*) ([0-9 ]+)$/doors:\1 \2 64 16/g' $COLORSTXT_PATH -i sed -re 's/^doors:(.*glass[^ ]*) ([0-9 ]+)$/doors:\1 \2 64 16/g' $COLORSTXT_PATH -i
# Fix xpanes color: # Fix xpanes color:
sed -re 's/^xpanes:(pane_[0-9]+|bar_[0-9]+) [0-9 ]+$/xpanes:\1 194 194 227 64 16/g' $COLORSTXT_PATH -i sed -re 's/^xpanes:(pane_[0-9]+|bar_[0-9]+) [0-9 ]+$/xpanes:\1 194 194 227 64 16/g' $COLORSTXT_PATH -i
==INSTRUCTIONS== ==INSTRUCTIONS==
1) Make sure avgcolors.py outputs the usage instructions 1) Make sure avgcolors.py outputs the usage instructions
2) Add the dumpnodes mod to Minetest 2) Add the dumpnodes mod to Minetest

2312
colors.txt

File diff suppressed because it is too large Load Diff