diff options
author | Momo <momorientes@online.de> | 2011-09-04 20:14:48 +0200 |
---|---|---|
committer | Momo <momorientes@online.de> | 2011-09-04 20:14:48 +0200 |
commit | 91d8afe4298e931ec1b59bd4bb7969e5889e67d5 (patch) | |
tree | caeb19583d10b2126db02cad7117bf716148b381 /god | |
parent | 89d86c1b9fa69cb6479997981f6302202aca830d (diff) |
adding lightzones and all
Diffstat (limited to 'god')
-rwxr-xr-x | god/licht | 101 |
1 files changed, 92 insertions, 9 deletions
@@ -1,20 +1,103 @@ #!/bin/bash -case "$1" in - (--help) echo "Toggle the lights";; - (*) - LAMPE=`echo $1 | sed -n '/^[1-2]*[0-9]*[0-9]$/p' | xargs echo "obase=16;" | bc` - TOGGLE=`echo $2 | sed -n '/^[0-1]/p'` +toggle() { + LAMPE=`echo "$1" | sed -n '/^[1-2]*[0-9]*[0-9]$/p' | xargs echo "obase=16;" | bc` + TOGGLE=`echo "$2" | sed -n '/^[0-1]/p'` if ! [ "$LAMPE" -a "$TOGGLE" ];then echo "you are made of stupid" exit 1 fi - STRING="\xA5\x5A\x$LAMPE\x$TOGGLE" + STRING="\\xA5\\x5A\\x$LAMPE\\x$TOGGLE" if [ $# != 2 ] then - echo -ne "Usage: licht <lampe> <0/1>" + echo "Usage: licht <lampe> <0/1>" else echo "Toggle light $LAMPE ($TOGGLE)" - echo -ne "$STRING" | nc -u -w1 licht.shack 1337 + printf "$STRING" | nc -u -w1 licht.shack 1337 fi - ;; +} + +toggle_all() { + for i in `seq 0 7` + do + printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + done + wait +} + +kuschel(){ + for i in 0 2 + do + printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + done + wait +} + +software(){ + for i in 1 3 + do + printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + done + wait +} + +tische(){ + for i in 4 6 + do + printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + done + wait +} + +ghetto(){ + printf "\\xA5\\x5A\\x7\\x$TOGGLE" | nc -u -w1 licht.shack 1337 +} + +porsche(){ + printf "\\xA5\\x5A\\x5\\x$TOGGLE" | nc -u -w1 licht.shack 1337 +} + +case "$1" in + --help) + echo "Toggle the lights" + echo "Usage: lich <lampe> <0/1>" + ;; + all) + TOGGLE=$2 + toggle_all + ;; + kuschel) + TOGGLE=$2 + kuschel + ;; + software) + TOGGLE=$2 + software + ;; + links) + TOGGLE=$2 + kuschel + software + ;; + rechts) + TOGGLE=$2 + tische + porsche + ghetto + ;; + tische) + TOGGLE=$2 + tische + ;; + porsche) + TOGGLE=$2 + porsche + ;; + ghetto) + TOGGLE=$2 + ghetto + ;; + *) + toggle "$@" + ;; esac + |