Linux Client Scripts
Linux Client Scripts
Running UNIX? Playing Sauerbraten? Often need to change between sets of options, like screen dimensions and shader settings? Here's a possible solution.
This is an example of how you could possibly handle your changing needs to run Sauerbraten on your linux machine. Please be sure to check your local documentation for possible changes to the number or usage of the parameters passed to the binary; since this page may be outdated in that respect, but the basics are here for those of you not as fluent in shell-scripting, adaptations should be painless.
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) # simple version: #ls -1 packages/base/*.ogz | cut -d '/' -f 3 | cut -d '.' -f 1 > maplines # complex version: # change the two following values to match your SB install DIR and home DIR SBP1=/opt/games/sauerbraten SBP2=/home/ogro/.sauerbraten find $SBP1 -type f -name "*.ogz"|sed 's/^.*\/\([^.]*\).ogz$/\1/' > maplines find $SBP2 -type f -name "*.ogz"|sed 's/^.*\/\([^.]*\).ogz$/\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 HTXT1="\033[36mSauerbraten Starter\033[m ver:\033[32m$version\033[m" HTXT2="call $0 with [mapname|-] [gFXindex] [-]" HTXT3="mapname from packages base for '-l', or '-' for a random map - see maplines and refresh_maplines for details." HTXT4="gFXindex must be valid in the case/esac block for" HELPTEXT="\n${HTXT1}\nby MeatROme\n${HTXT2}\n\n\n${HTXT3}\n${HTXT4} \$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