Automatizing automatizer
Posted: Tue Jun 30, 2015 7:48 pm
Remembered about my old old script and .prf file from times when I decided not to write automat.atm by hand but to generate it from the start of every new game by destroying certain unneeded items. I found it more handy comparing to any universal pre-written rules. Ok, more controllable at least.
I use F8 and F9 keys to "destroy and add rule" for item on the floor (by type and by family respectively), and F10 to "save rules and exit":
Also I wrote this script to erase dupes from automat.atm, and to have more sensible names like "d RING" or "d POTION" instead of this bunch of nameless "destroy"-s:
Maybe someone else will find it useful.
I use F8 and F9 keys to "destroy and add rule" for item on the floor (by type and by family respectively), and F10 to "save rules and exit":
Code: Select all
A:\e\e\e\e\e\e\e\e\e\e099^D$-\ry\sST
P:\[F8]
A:\e\e\e\e\e\e\e\e\e\e099^D$-\ry\sSF
P:\[F9]
A:\e\e\e\e\e\e\e\e\e\e=Ts\ry\s\e\e^X\e
P:\[F10]
Code: Select all
#!/bin/bash
d=$HOME/.tome/2.4
a=$d/automat.atm
[ -f $a ] && {
cat $a | tr '\n' ' ' | tr -s ' ' | sed 's/{\s*"action":/\n&/g; s/\s*]\s*$/\n]/' |
grep '^{' | sort -u >$a.tmp
grep -o 'TV_[a-Z0-9_]*]* *[0-9][0-9]*' <lib/help/defines.txt | tr -d ']' | sed s/TV_// |
while read tv n; do
sed -i '/"tval": '$n',/ s/"name": "destroy"/"name": "d '$tv'"/' $a.tmp
done
{ echo \[
grep -o '"name":[^}]*' $a.tmp | cut -d \" -f4 | sort -u | while read n; do
grep '"name": "'"$n"\" $a.tmp
done | sed 's/}$/},/; $ s/},\s*$/}/'
echo \]
} >$a
rm $a.tmp
}
./src/tome