summaryrefslogtreecommitdiff
path: root/share/hackvr/examples/dungen/dunexplore.sh
blob: 6f713914ee31cedecfcf13c3807b2b4bebb643f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
### run me with hackvr_coproc
#the $USER triangle we add first is to give us some sort of avatar to see where the camera is.
#seed=1337
echo $USER addshape 4 3  -1 0 -1  0 0 2  1 0 -1 ; echo $USER move 0 2 0
./dungen $seed | ./dun2hackvr
while read group action target;do
  if [ "$action" = "action" ];then
    if printf "%s\n" "${target}" | grep ^door_;then
      printf "# clicked a door! %s\n" "${target}" >&2
      if printf "%s\n" "${target}" | grep ^door_open;then
        tmp=$(printf "%s\n" "${target}" | sed 's/_open/_CLOSING/')
        printf "%s renamegroup %s %s\n" ${target} ${target} ${tmp} 
        (
        for i in $(seq 1 5 90);do
          printf "%s rotate 0 +5 0\n" ${tmp}
          sleep .1
        done
        tmp2=$(printf "%s\n" "${target}" | sed 's/_open/_close/')
        printf "%s renamegroup %s %s\n" ${tmp} ${tmp} ${tmp2}
        ) &
      elif printf "%s\n" "${target}" | grep ^door_close;then
        tmp=$(printf "%s\n" "${target}" | sed 's/_close/_OPENING/')
        printf "%s renamegroup %s %s\n" ${target} ${target} ${tmp}
        (
        for i in $(seq 1 5 90);do
          printf "%s rotate 0 +-5 0\n" ${tmp}
          sleep .1
        done
        tmp2=$(printf "%s\n" "${target}" | sed 's/_close/_open/')
        printf "%s renamegroup %s %s\n" ${tmp} ${tmp} ${tmp2}
        ) &
      fi
    fi 
  fi
done