Hello! I am having trouble with generating a script to load a demo, go to a tick, go to a players POV, wait for a bit and go to the next.
Here is basically what I use to generate one:
#!/bin/bash
DEMOFILE=~/tf/tf/demos/$(basename "$1")
PARSER=tfdemoparse
RECORD_BUFFER=1000
function _() {
echo -n "$*;"
}
function gen-header() {
_ "echo starting" $1
_ "sv_cheats 1"
_ "sv_allow_wait_command 1"
_ "playdemo demos/$(basename -s .dem $1)"
_ "wait 10000"
}
function gen-stemp() {
_ "echo --------------> going to " $(($1 - RECORD_BUFFER))
_ "demopause"
_ "demo_gototick" $(($1 - RECORD_BUFFER))
_ "wait 5000"
_ "spec_player LabRicecat"
_ "spec_mode 4"
_ "demo_resume"
_ "wait" $((RECORD_BUFFER * 5))
}
function gen-tail() {
_ "stopdemo"
_ "echo done loading"
}
function get-drops() {
"$PARSER" "$DEMOFILE" | jq | grep -A 1 "DROPPED" | grep -Eo "[0-9]+"
}
if [[ ! -f "$DEMOFILE" ]]; then
return 1 >/dev/null 2>&1
exit 1
else
DROPS=$(get-drops "$DEMOFILE")
if [[ ! -z "$DROPS" ]]; then
gen-header "$DEMOFILE"
for i in $(get-drops); do
gen-stemp $i
done
gen-tail
fi
fi
The problem seem to be the wait commands, as they are not synced. They either end too early or are just not where I want my demo to start.
This is indeed kind of a hack, but has someone an idea on what I did wrong tf2 scripting wise?