1 | #!/bin/bash
|
---|
2 | # requires:
|
---|
3 | # imagemagick, bc
|
---|
4 |
|
---|
5 | #map = 6x6 blocks
|
---|
6 | #one block: 512
|
---|
7 | #image size: 1536x1536
|
---|
8 |
|
---|
9 | cd /home/sdtd/7draw/
|
---|
10 |
|
---|
11 | TELNET_PWD=volume7
|
---|
12 | TELNET_PORT=8081
|
---|
13 | #. /etc/7dtd.conf
|
---|
14 |
|
---|
15 | RADIUS=5
|
---|
16 | LP=`echo -e "$TELNET_PWD\nlp" | nc -q 2 localhost $TELNET_PORT`
|
---|
17 | POSLINES=`echo "$LP" | grep -oE "pos=\([^)]*\)"`
|
---|
18 | # remove brackets
|
---|
19 | POSLINES=`echo "$POSLINES" | tr -d ")("`
|
---|
20 |
|
---|
21 | #enable for debug
|
---|
22 | #POSLINES="-221.7, 85.0, -684.6\n221.7, 85.0, 684.6"
|
---|
23 | if [ -n "$POSLINES" ]; then
|
---|
24 | DATE=`date +"%Y.%m.%d"`
|
---|
25 | HOUR=`date +"%H"`
|
---|
26 | MIN=`date +"%M"`
|
---|
27 | HUE=`echo "(100 * (($HOUR * 60) + $MIN)) / 1440" | bc`
|
---|
28 | COLOR="hsb($HUE%, 100%, 100%)"
|
---|
29 | IMG_OUT="map_$DATE.png"
|
---|
30 | if [ ! -f "$IMG_OUT" ]; then
|
---|
31 | IMG_IN=NavezganeMap.png
|
---|
32 | else
|
---|
33 | IMG_IN="$IMG_OUT"
|
---|
34 | fi
|
---|
35 | echo -e "$POSLINES" | while IFS=", " read x _ y
|
---|
36 | do
|
---|
37 | X=`echo "768 - $x/2" | bc`
|
---|
38 | Y=`echo "768 - $y/2" | bc`
|
---|
39 | X2=`echo "$X+$RADIUS" | bc`
|
---|
40 | Y2=`echo "$Y+$RADIUS" | bc`
|
---|
41 | `convert "$IMG_IN" -fill "$COLOR" -draw "circle $X,$Y $X2,$Y2" "$IMG_OUT"`
|
---|
42 | IMG_IN="$IMG_OUT"
|
---|
43 | done
|
---|
44 | fi
|
---|