Table of Contents

The Scripts
update_maplines
run_sb
You can have your game start in a random map every time, if you like :
The following 2 scripts should be placed in your sauerbraten installation directory and made executable (chmod +x).
Then run update_maplines and modify run_sb in the section for
case $2 in

The values for your configurations 1-6 and * (for default) should correspond to :
SW ..... screen width ......... (-w)
SH ..... screen height ........ (-h)
PD ..... pixel depth .......... (-b)
ZB ..... Z-buffer ............. (-z)
FX ..... Shader FX ............ (-f)
AF ..... Ansiotropic Filter ... (-a)
WM ..... windowed mode ........ (-t)

You'll need to have bogosort installed for the map randomization to work and keeping the list up-to-date requires regularly running update_maplines.

The Scripts


update_maplines

#!/bin/sh
# if you require backups unremark the following line
#mv maplines old_maplines_$(date +%Y%m%d%H%M%S)
ls -1 packages/base/*.ogz | cut -d '/' -f 3 | cut -d '.' -f 1 > maplines


run_sb

#!/bin/sh
version=0.1
RMN=$(bogosort -n --seed=$(timestamp $(date +%Y%m%d%H%M%S)) ./maplines | tail -n 1)
CMD=""
WM=0
 
HELPTEXT="\n\033[36mSauerbraten Starter\033[m ver:\033[32m$version\033[m\nby MeatROme\n\ncall $0 with [mapname|-] [gFXindex] [-]\n\nmapname from packages base for '-l', or '-' for a random map - see maplines and refresh_maplines for details.\ngFXindex must be valid in the case/esac block for \$2.\n\n"
# ---------------------------------------------------------------
 
#
# call with [-|mapname] [setup-index]
#
# like :
# run_sb ........ random map, default setup
# run_sb - 1 .... random map, alternative setup #1
# run_sb cdf .... start with map cdf, default setup
# run_sb cdf 2 .. start with map cdf, alternative setup #2
 
#echo "Random Map would be $RMN"
 
#
# ---------------------------------------------------------------
#
# fullscreen     : 1 2
# windowed         : 3 4 
# mini window    : 5 6
#
# ---------------------------------------------------------------
#
 
case $1 in
    -) MLC="-l$RMN";; 
    ?)     echo -e "$HELPTEXT"
        case $2 in
            [1-6])
                LOB=$(grep -n "$2)" $0 | grep SW | cut -d ':' -f 1 | tail -n 1)
                LOE=$(head -n $(echo "$LOB+6" | bc) $0 | tail -n 1 | cut -d ')' -f 2 | tr -d '&;' | tr -d ' ' | tr '\t=' '  ')
                echo -e "\033[1;32m$2:\033[m\n$LOE\n"            ;;
            *);;
        esac
        exit;;
    *) MLC="-l$1";;
esac
 
if [ "$MLC" == "-l" ]
then
    MLC="-l$RMN"
fi
 
# EDIT YOUR CONFIG HERE ::
case $2 in
    1)     SW=1024    &&  SH=768    &&    PD=16    &&    ZB=24    &&    FX=1    &&    AF=2    &&    WM=0;;
    2)     SW=1024    &&  SH=768    &&    PD=16    &&    ZB=24    &&    FX=""    &&    AF=0    &&    WM=0;;
    3)     SW=1024    &&  SH=768    &&    PD=16    &&    ZB=24    &&    FX=""    &&    AF=0    &&    WM=1;;
    4)     SW=800  &&  SH=600    &&    PD=16    &&    ZB=24    &&    FX=""    &&    AF=0    &&    WM=1;;
    5)     SW=640  &&  SH=480    &&    PD=16    &&    ZB=24    &&    FX=1    &&    AF=2    &&    WM=1;;
    6)     SW=640  &&  SH=480    &&    PD=16    &&    ZB=24    &&    FX=""    &&    AF=0    &&    WM=1;;
    *)     SW=1280    &&  SH=1024    &&    PD=16    &&    ZB=24    &&    FX=1    &&    AF=1    &&    WM=0;;
esac
# :: EDIT YOUR CONFIG HERE
 
GEP="-w$SW -h$SH -b$PD -z$ZB -f$FX -a$AF"
if [ "$WM" == "1" ] 
then
    GEP="$GEP -t"
fi
SEP="$MLC $GEP"
 
CMD="./sauerbraten_unix $SEP" 
 
# ---------------------------------------------------------------
 
echo -e "\nrunning SAUERBRATEN ...\n"
echo $CMD
$CMD
echo 
echo ... finished.
echo