minor refactoring, timing

This commit is contained in:
Egan Ford 2017-06-03 14:59:40 -06:00
parent b7b32ec993
commit 92f183f045
4 changed files with 15 additions and 28 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# needs better error handling, zxing returns true on fail, test with Stellar Invaders
set -e set -e
tifftopnm <$1 2>/dev/null | pnmtojpeg >decode.jpg tifftopnm <$1 2>/dev/null | pnmtojpeg >decode.jpg

18
demo.sh
View File

@ -9,17 +9,13 @@ then
DEMO=1 DEMO=1
fi fi
RAND=0
if [ "$GAME" = "random" ] if [ "$GAME" = "random" ]
then then
GAME="" ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | wc -l)
RAND=1 LINE=$(( RANDOM % ITEMS + 1))
fi else
ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -i "$GAME" | wc -l)
ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -i "$GAME" | wc -l)
if (( RAND == 0 ))
then
if (( ITEMS == 0 )) if (( ITEMS == 0 ))
then then
echo "game $GAME not found" >&2 echo "game $GAME not found" >&2
@ -38,14 +34,10 @@ then
fi fi
LINE=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -ni "$GAME" | head -$ITEM | tail -1 | awk -F: '{print $1}') LINE=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -ni "$GAME" | head -$ITEM | tail -1 | awk -F: '{print $1}')
else
LINE=$(( RANDOM % ITEMS + 1))
fi fi
GAME=$(curl -sL http://asciiexpress.net/gameserver/links.html | sort | head -$LINE | tail -1 | awk -F\" '{print $4 "," $6}' | sed 's/.html$/.qr.wav/')
DOWN=$((LINE - 1)) DOWN=$((LINE - 1))
TITLE=$(echo $GAME | awk -F, '{print $1}') TITLE=$(curl -sL http://asciiexpress.net/gameserver/links.html | sort | head -$LINE | tail -1 | awk -F\" '{print $4}')
echo echo
echo -n "${TITLE}..." echo -n "${TITLE}..."

View File

@ -5,7 +5,7 @@ on run argv
set my_timeout1 to item 3 of argv set my_timeout1 to item 3 of argv
set my_screen2 to item 4 of argv set my_screen2 to item 4 of argv
set my_timeout2 to item 5 of argv set my_timeout2 to item 5 of argv
set my_down to item 6 of argv set my_down to item 6 of argv as number
set my_demo to item 7 of argv as number set my_demo to item 7 of argv as number
tell application "Virtual ][" tell application "Virtual ]["
@ -76,8 +76,9 @@ on run argv
set speed to maximum set speed to maximum
end if end if
if (my_demo = 1) then if (my_demo = 1) then
delay my_audiotime delay (my_audiotime + 0.5)
end if end if
-- will need to be ajusted based on speed of your mac
delay 1.5 delay 1.5
-- normal speed -- normal speed
set speed to regular set speed to regular

View File

@ -9,17 +9,13 @@ then
DEMO=1 DEMO=1
fi fi
RAND=0
if [ "$GAME" = "random" ] if [ "$GAME" = "random" ]
then then
GAME="" ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | wc -l)
RAND=1 LINE=$(( RANDOM % ITEMS + 1))
fi else
ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -i "$GAME" | wc -l)
ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -i "$GAME" | wc -l)
if (( RAND == 0 ))
then
if (( ITEMS == 0 )) if (( ITEMS == 0 ))
then then
echo "game $GAME not found" >&2 echo "game $GAME not found" >&2
@ -38,14 +34,10 @@ then
fi fi
LINE=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -ni "$GAME" | head -$ITEM | tail -1 | awk -F: '{print $1}') LINE=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort | grep -ni "$GAME" | head -$ITEM | tail -1 | awk -F: '{print $1}')
else
LINE=$(( RANDOM % ITEMS + 1))
fi fi
GAME=$(curl -sL http://asciiexpress.net/gameserver/links.html | sort | head -$LINE | tail -1 | awk -F\" '{print $4 "," $6}' | sed 's/.html$/.qr.wav/')
DOWN=$((LINE - 1)) DOWN=$((LINE - 1))
TITLE=$(echo $GAME | awk -F, '{print $1}') TITLE=$(curl -sL http://asciiexpress.net/gameserver/links.html | sort | head -$LINE | tail -1 | awk -F\" '{print $4}')
echo echo
echo -n "${TITLE}..." echo -n "${TITLE}..."