This guide was written as if you were using ubuntu 14.04 server.
First off, we need to install some dependencies, do this with the following:
Code: Select all
apt-get install xorg xfce4-session x11vnc xdotoolnow, we're going to start a screen and xdummy interface
Code: Select all
screen -R x
sudo Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./10.log -config ./xorg.conf :10We now need to start xfce on xdummy, as xdotool (which I used for my pausing script) needs a window manager.
Code: Select all
screen -R xfce
export DISPLAY=:10
startxfce4Now, we need to turn off xfce's screensaver, this might cause some issues if you skip this step
Code: Select all
xset s offDownload factorio, and upload it to your server
back at the server, we need to create a save directory, and make factorio executable
Code: Select all
cd factorio
chmod +x bin/x64/factorio
mkdir savesIn your new savefile, type the following into the console:
Code: Select all
/c local char = game.players[1].character; game.players[1].character = nil; char.die()Back to the server, we need to make a script for launching factorio
Code: Select all
cd
nano startfactorioCode: Select all
#!/bin/bash
name="mapname.zip"
~/factorio/bin/x64/factorio --mp-load-game $name #assumes 64 bit now, we need to change startfactorio's permissions
Code: Select all
chmod +x startfactorioCode: Select all
screen -R factorio
export DISPLAY=:10
./startfactorioThe last thing left is the autopauser script (prevents biters from destroying your base when you are offline).
Code: Select all
screen -R pauser
nano pauser
Code: Select all
	
    #!/bin/bash
    PATHTOLOG="/root/factorio/factorio-current.log"
     
    OLDPLAYERCOUNT=0
    PLAYERCOUNT=0
    NUMBEROFLINESOLD=0
     
    while :; do
      #get the current nuber of log entries
      NUMBEROFLINES=$(wc -l /root/factorio/factorio-current.log | grep -o "[0-9]\+")
      ABSOLUTELINES=$((NUMBEROFLINES-NUMBEROFLINESOLD))
      #only look at new lines
      TAILEDLOG=$(tail -$ABSOLUTELINES $PATHTOLOG)
      #grab Joins PlayerJoinGame
      JOINSGAME=$(echo $TAILEDLOG | grep "MultiplayerManager changing state from(InGameSendingMap) to(InGame)" | wc -l | grep -o "[0-9]\+")
      #grab peer leaving
      QUITS=$(echo $TAILEDLOG | grep "PlayerLeaveGame" | wc -l | grep -o "[0-9]\+")
      #grab peer timeout
      DROPOUTS=$(echo $TAILEDLOG | grep "is not responding, dropping" | wc -l | grep -o "[0-9]\+")
      BOOT=$(echo $TAILEDLOG | grep "MultiplayerManager changing state from(CreatingGame) to(InGame)" | wc -l | grep -o "[0-9]\+")
      QUITS=$((QUITS+DROPOUTS))
      echo "QUITS: "$QUITS
      JOINS=$((JOINSGAME))
      echo "JOINS: "$JOINS
      echo "JOINSGAME:"$JOINSGAME
      PLAYERCOUNT=$((PLAYERCOUNT+JOINS))
      PLAYERCOUNT=$((PLAYERCOUNT-QUITS))
      if [ $BOOT -eq 1 ]
      then
        WID=$(xdotool search Factorio 2>/dev/null)
        xdotool windowactivate --sync $WID
        xdotool key Escape
        xdotool key shift+space
      fi
     
      if [ $PLAYERCOUNT -eq 1 -a $OLDPLAYERCOUNT -eq 0 ]
      then
        echo "detected players, unpausing"
        WID=$(xdotool search Factorio 2>/dev/null)
        xdotool windowactivate --sync $WID
        xdotool key shift+space
      fi
      if [ $PLAYERCOUNT -eq 0 -a $OLDPLAYERCOUNT -eq 1 ]
      then
        echo "0 players, pausing"
        WID=$(xdotool search Factorio 2>/dev/null)
        xdotool windowactivate --sync $WID
        xdotool key shift+space
      fi
     
     
      #REMOVE the following line if you don't want to see current players.
      echo $PLAYERCOUNT
     
      OLDPLAYERCOUNT=$PLAYERCOUNT
      NUMBEROFLINESOLD=$NUMBEROFLINES
      #change to number of seconds between player count update [default: 1 sec]
      sleep 1
    done
Code: Select all
chmod +x pauser
export DISPLAY=:10
./pauserhopefully, everything should be running at this point
the pauser script will require a restart after desyncs.






 )
 )